我已完成本教程http://www.protractortest.org/#/tutorial的所有内容
和
https://github.com/angular/protractor-cookbook/tree/master/protractor-docker
(我最近从隔离的硒中心和节点更改为https://hub.docker.com/r/selenium/standalone-chrome/)
我创建了一个protractor.config.js:
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4455/wd/hub',
specs: ['../tests/protractor/spec.js'],
}
我在test / protractor / spec.js中的测试
// spec.js
describe('Protractor Demo App', function() {
it('should add one and two', function() {
browser.get('http://juliemr.github.io/protractor-demo/');
element(by.model('first')).sendKeys(1);
element(by.model('second')).sendKeys(2);
element(by.id('gobutton')).click();
expect(element(by.binding('latest')).getText()).
toEqual('5'); // This is wrong!
});
});
这些是我的硒中心和铬节点:
docker run -d -p 4455:4444 --name selenium-hub selenium/hub:latest
docker run -d --link selenium-hub:hub selenium/node-chrome:latest
给出了这些docker容器:
806106331d22 selenium/node-chrome:latest "/opt/bin/entry_point" 23 seconds ago Up 22 seconds insane_newton
d93265006f9d selenium/hub:latest "/opt/bin/entry_point" 37 minutes ago Up 37 minutes 0.0.0.0:4455->4444/tcp selenium-hub
这是最新发生的事情:
./node_modules/.bin/protractor tests/config/protractor.conf.js
[16:01:28] I/launcher - Running 1 instances of WebDriver
[16:01:28] I/hosted - Using the selenium server at http://localhost:4455/wd/hub
一分钟后我得到这个错误:
[12:32:34] E/launcher - WebDriverError: unknown error: Chrome failed to start: exited normally
(Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.4.4-200.fc22.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.03 seconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: '923fd0282cf0', ip: '172.17.0.27', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.4-200.fc22.x86_64', java.version: '1.8.0_131'
Driver info: driver.version: ChromeDriver
at WebDriverError (node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:27:5)
at Object.checkLegacyResponse (node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:505:15)
at parseHttpResponse (node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:440:13)
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebDriver.createSession()
at Function.createSession (node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:777:24)
at Function.createSession (node_modules/protractor/node_modules/selenium-webdriver/chrome.js:709:29)
at createDriver (node_modules/protractor/node_modules/selenium-webdriver/index.js:167:33)
at Builder.build (node_modules/protractor/node_modules/selenium-webdriver/index.js:623:16)
at Hosted.getNewDriver (node_modules/protractor/lib/driverProviders/driverProvider.ts:60:29)
at Runner.createBrowser (node_modules/protractor/lib/runner.ts:225:39)
at q.then.then (node_modules/protractor/lib/runner.ts:391:27)
at _fulfilled (node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (node_modules/protractor/node_modules/q/q.js:796:13)
[12:32:34] E/launcher - Process exited with error code 199
可能是什么原因?
答案 0 :(得分:1)
请在conf文件和spec文件中添加以下内容,然后运行
browser.ignoreSynchronization=true;
并在使用URL
启动浏览器后添加等待时间 browser.sleep(5000);
并在Conf文件中使用Jasmine默认超时间隔和功能
显式添加 browserName:"chrome"
请确保Conf和Spec文件位于同一位置。
答案 1 :(得分:1)
exports.config = {
capabilities: {
'browserName': 'chrome'
},
framework: 'jasmine',
seleniumAddress: 'http://localhost:4455/wd/hub',
specs: ['../tests/protractor/spec.js'],
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
};