3

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!!!

Shir Avr
  • 51
  • 1
  • 5
  • Can you also tell us the versions of Chrome and Chromedriver which you are using. Chrome has just been updated to version 59 so you need to have ChromeDriver 2.30 – wswebcreation Jun 17 '17 at 04:49
  • google-chrome --version -> `Google Chrome 59.0.3071.104` chromedriver --version -> `ChromeDriver 2.30.477691` also: `webdriver-manager@12.0.6` and `protractor@5.1.2` – Shir Avr Jun 17 '17 at 11:03
  • Hope this might help you https://stackoverflow.com/questions/39080917/how-to-run-protractor-testcases-in-jenkin-with-a-headless-browser – Sudharsan Selvaraj Jun 23 '17 at 04:57

2 Answers2

13

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

Raony Benjamim
  • 131
  • 1
  • 4
  • 2
    `no-sandbox` is exactly what fixed my issue in an Ubuntu Server 16.04 machine on Azure. thank you! – crookedleaf Nov 10 '17 at 21:32
  • It works for me. For later versions, arg chrome_options is deprecated and replaced by options. – Louis Sep 12 '19 at 15:28
  • Also, in my case I don't need no-sandbox option. It seems to be safer not using that if possible. – Louis Sep 12 '19 at 18:44
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.

Shir Avr
  • 51
  • 1
  • 5