-->

WebDriverError error: Chrome failed to start: exit

2019-04-11 00:33发布

问题:

I'm trying to run protractor test on ubuntu 14.04 vm (by google cloud), for some reason when i run 'protractor conf.js' i get an error says:

E/launcher - WebDriverError: unknown error: Chrome failed to start: exited abnormally

I followed this tasks in order to install headless chrome: https://gist.github.com/alonisser/11192482

  • Before running protractor cons.js, i'm running "webdriver-manager start"

  • When i run 'Xvfb -ac :2 -screen 0 1280x1024x16' its freeze when gets to 'Initializing built-in extension GLX'

  • I also tried change the conf.js to chromeOptions: { args: [ "--headless", "--disable-gpu", "--window-size=800x600" ]' but and protractor print 'start' then error: 'Failed: unknown error: an X display is required for keycode conversions, consider using Xvfb'

  • It's important to mention that it's all worked great, before a couple hours. then i just let my mac sleep, and of course it was exit the vm..

  • I'm running the same tests with protractor in my mac and its works great. the problem is related to chrome/chromeDriver on the instance vm.

thanks a lot!!!

回答1:

I had a similar problem when using selenium + python 2.7 + chromedriver in a AWS EC2 machine.

In my case I was using the newest headless feature, so adding 'no-sandbox' parameter to the ChromeOptions object did the trick.

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('headless')
chrome_options.add_argument('no-sandbox')
driver = webdriver.Chrome(chrome_options=chrome_options)

The problem seems to be a permission issue with chrome. It does not allow a 'root' user to execute it without the --no-sandbox flag



回答2:

Turned out, the answer is in my question.

You should run the command Xvfb -ac :99 -screen 0 1280x1024x16

and right after export DISPLAY=:99

I also add to my start.sh script the command export DISPLAY=:99 The order seems to be important. You can ignore the error of the GLX when running the Xvfb, it can work without it.