Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webdriver randomly produces 'chrome not reachable' on Linux tests

Our CI tests fail randomly with 'chrome not reachable' error. Initially they were quite rare, but as our test base grows, it has become intolerable. There are several other questions / bug reports about this, but none of these seem to relate to our case.

The tests are written with Cucumber + Ruby + Watir-Webdriver + Selenium-Webdriver (latest versions of each gem). We're running the tests on Ubuntu Linux 12.04 in headless mode using xvfb on physical hardware (no virtualization). I can reproduce it quite reliably on my laptop running Linux Mint 16. We're running the tests in parallel for speeding up things.

I've tried using both Chromium 18.0.1025.151~r130497-0ubuntu1 and Google Chrome 34.0.1847.116, with ChromeDriver v2.9.248304. The same problem has occurred with older versions of the browser and ChromeDriver as well.

Typically several tests fail in a row due to the same error and then is starts working again on a later test during the same run.

The stack trace is:

  chrome not reachable
    (Session info: chrome=34.0.1847.116)
    (Driver info: chromedriver=2.9.248304,platform=Linux 3.2.0-60-generic x86_64) (Selenium::WebDriver::Error::WebDriverError)
  /home/weller/jenkins/workspace/TEST_CHROME_C/server/cucumber/support/step_support/browsers.rb:14:in `goto'
  /home/weller/jenkins/workspace/TEST_CHROME_C/server/cucumber/support/step_support/browsers.rb:35:in `blank_page'
  /home/weller/jenkins/workspace/TEST_CHROME_C/server/cucumber/support/step_support/browsers.rb:44:in `add_cookie'
  ./features/support/mocking.rb:11:in `mock'
  ./features/support/time_steps.rb:5:in `/^the current time zone is "(.*?)"$/'
  features/trackers/mood/mood_data_entry.feature:7:in `And the current time zone is "GMT+4"'

Update: The problem seems to be related to the parallelism. When one of the tests exit, there's a chance that another one will start failing with 'chrome not reachable'. If I add a delay to the end of the tests, so that all tests have finished before any Chrome windows are closed, the tests run without problem. I reported a bug against ChromeDriver about the issue.

like image 496
Sampo Avatar asked Apr 11 '14 13:04

Sampo


People also ask

Does ChromeDriver work on Linux?

The ChromeDriver controls the browser using Chrome's automation proxy framework. For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary. See also the section on overriding the Chrome binary location.

How do I know if ChromeDriver is running on Linux?

Execute google.py - A new chrome browser is open and redirect to www.google.com. Execute yahoo.py - If webdriver. Chrome is executed/existed, then assign the browser to driver variable. Else launch new browser.

Can Linux server run Selenium?

So, Selenium can do web automation, web scrapping, browser tests, etc. using the Chrome web browser in Linux servers where you don't have any graphical desktop environment installed. In this article, I am going to show you how to run Selenium with the Chrome web browser in headless mode.


1 Answers

I had the same problem, in my case it was because user-data-dir, which is randomly created by chromedriver, in some cases was the same for several tests. I solved it by synchronizing webdriver creation (performance is not affected by this)

like image 74
cocorossello Avatar answered Sep 22 '22 18:09

cocorossello