pro拖拉机+ Selenium + Selenium Docker = WebDriverError:未知错误:Chrome启动失败:正常退出

时间:2021-02-12 18:21:02

I have done everything from this tutorial http://www.protractortest.org/#/tutorial
and
https://github.com/angular/protractor-cookbook/tree/master/protractor-docker

我已经完成了本教程http://www.protractortest.org/#/教程和https://github.com/angular/protrac-cookbook/tree/master/protrac-docker。

(i recently changed from sepereated selenium hub and node to https://hub.docker.com/r/selenium/standalone-chrome/)

(我最近从sepereated selenium hub和node更改为https://hub.docker.com/r/selenium/standone -chrome/)

i have created a protractor.config.js:

我创建了一个protractor.config.js:

exports.config = { 
  framework: 'jasmine', 
  seleniumAddress: 'http://localhost:4455/wd/hub', 
  specs: ['../tests/protractor/spec.js'], 
}

my test inside tests/protractor/spec.js

我的测试在测试/量角器/ 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!
  });
});

these are my selenium hub and chrome node:

这是我的selenium hub和chrome node:

docker run -d -p 4455:4444 --name selenium-hub selenium/hub:latest
docker run -d --link selenium-hub:hub selenium/node-chrome:latest

that gives these docker containers:

这些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

and this is whats happening:

这就是为什么

./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

after one minute i get this error:

一分钟后我就犯了这个错误:

[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

What could be the reason?

原因是什么呢?

2 个解决方案

#1


1  

exports.config = {                                                                   
  capabilities: {                                                       
    'browserName': 'chrome'                                             
  },                                                                           
  framework: 'jasmine',                                                                                              
  seleniumAddress: 'http://localhost:4455/wd/hub', 
  specs: ['../tests/protractor/spec.js'],                                                                       
  jasmineNodeOpts: {                                                    
    defaultTimeoutInterval: 30000                                       
  }                                                                     
};                                                                      

#2


1  

Please add below things in conf file and spec file, then run

请在conf文件和spec文件中添加以下内容,然后运行

   browser.ignoreSynchronization=true;

and add wait time after browser is launched with URL

并添加浏览器启动后的等待时间

   browser.sleep(5000);

and in Conf file add explicitly with Jasmine default timeout Interval and in Capabilities

并且在Conf文件中显式添加了Jasmine默认超时间隔和功能

   browserName:"chrome" 

Please Make sure both Conf and Spec files are in same location.

请确保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                                       
  }                                                                     
};                                                                      

#2


1  

Please add below things in conf file and spec file, then run

请在conf文件和spec文件中添加以下内容,然后运行

   browser.ignoreSynchronization=true;

and add wait time after browser is launched with URL

并添加浏览器启动后的等待时间

   browser.sleep(5000);

and in Conf file add explicitly with Jasmine default timeout Interval and in Capabilities

并且在Conf文件中显式添加了Jasmine默认超时间隔和功能

   browserName:"chrome" 

Please Make sure both Conf and Spec files are in same location.

请确保Conf和Spec文件位于同一位置。