[英]how to run protractor tests in docker-compose
I have problem with start test using protractor framework using docker image. 我在使用使用docker image的量角器框架进行启动测试时遇到问题。 When i start test in my local selenium server the tests is succeed.
当我在本地硒服务器中开始测试时,测试成功。 but when i use docker image i got error E/protractor - Could not find Angular on page http://localhost:4200/ : retries looking for angular exceeded .
但是当我使用docker image时出现错误E /量角器-无法在页面http:// localhost:4200 /上找到Angular:重试以寻找超出角度的角度 。
my config.js 我的config.js
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://hub:4444/wd/hub',
specs: ['e2e/myTest.js'],
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
args: ['--no-sandbox']
}
},
chromeOnly: true
};
myTest.js myTest.js
describe('example test', function() {
var homePage = require('./pages/homePage.js');
var homePage = new homePage();
it('my test...', function() {
browser.get('http://localhost:4200/');
....
Package.json file Package.json文件
{
"name": "client",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "npm install && ng serve -H 0.0.0.0",
"build": "ng build",
"pretest": "webdriver-manager update",
"test": "protractor config.js",
"lint": "ng lint"
},
Fragment of docker-compose.yml docker-compose.yml的片段
angular:...
mypayara:...
chrome:
image: selenium/node-chrome:3.9.1-actinium
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub
hub:
image: selenium/hub:3.9.1-actinium
ports:
- "4444:4444"
depends_on:
- angular
When i start test using command 当我使用命令开始测试时
docker-compose exec angular sh -c "npm test"
docker-compose exec angular sh -c“ npm test”
i got that error 我得到那个错误
[18:51:48] E/protractor - Could not find Angular on page http://localhost:4200/ : retries looking for angular exceeded
F[18:51:59] E/protractor - Could not find Angular on page http://localhost:4200/ : retries looking for angular exceeded
F
Failures:
1) Register account test should create a account
Message:
Failed: Angular could not be found on the page http://localhost:4200/.If this is not an Angular application, you may need to turn off waiting for Angular.
Please see
https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load
Stack:
Error: Angular could not be found on the page http://localhost:4200/.If this is not an Angular application, you may need to turn off waiting for Angular.
Please see
https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load
at executeAsyncScript_.then (/usr/src/app/node_modules/protractor/built/browser.js:720:27)
at ManagedPromise.invokeCallback_ (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:1376:14)
at TaskQueue.execute_ (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:3084:14)
at TaskQueue.executeNext_ (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:3067:27)
at asyncRun (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:2927:27)
at /usr/src/app/node_modules/selenium-webdriver/lib/promise.js:668:7
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: Run it("should create a account") in control flow
at UserContext.<anonymous> (/usr/src/app/node_modules/jasminewd2/index.js:94:19)
From asynchronous test:
Error
at Suite.<anonymous> (/usr/src/app/e2e/registertest.js:7:3)
at Object.<anonymous> (/usr/src/app/e2e/registertest.js:1:63)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
I have problem with connect with my docker apps. 我在连接docker应用程序时遇到问题。 I am trying this test and result is success.
我正在尝试此测试,结果是成功。
describe('angularjs homepage todo list', function() {
it('should add a todo', function() {
browser.get('https://angularjs.org');
element(by.model('todoList.todoText')).sendKeys('write first protractor test');
element(by.css('[value="add"]')).click();
var todoList = element.all(by.repeater('todo in todoList.todos'));
expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write first protractor test');
// You wrote your first test, cross it off the list
todoList.get(2).element(by.css('input')).click();
var completedAmount = element.all(by.css('.done-true'));
expect(completedAmount.count()).toEqual(2);
});
});
Do you have any idea what i can do with this problem? 您知道我可以解决这个问题吗?
just to check if the reason is Angular, add this line to your code in 'it' block. 只是要检查原因是否为Angular,请将此行添加到代码中的“ it”块中。
await browser.waitForAngularEnabled(false);
and watch what is happening 看看发生了什么
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.