DEV Community

Marcin K.
Marcin K.

Posted on

Mysterious "chrome not reachable" WebDriverError in Selenium

Today I would like to share what I have learned regarding "chrome not reachable" error.

I came across this one when I tried to find an element right after navigating to a particular address. Stacktrace looked like this:

Traceback (most recent call last):
         9: from /Users/marcin/.gem/ruby/2.6.5/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/search_context.rb:62:in `find_element'
         8: from /Users/marcin/.gem/ruby/2.6.5/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/oss/bridge.rb:554:in `find_element_by'
         7: from /Users/marcin/.gem/ruby/2.6.5/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/oss/bridge.rb:587:in `execute'
         6: from /Users/marcin/.gem/ruby/2.6.5/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:167:in `execute'
         5: from /Users/marcin/.gem/ruby/2.6.5/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/common.rb:64:in `call'
         4: from /Users/marcin/.gem/ruby/2.6.5/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:114:in `request'
         3: from /Users/marcin/.gem/ruby/2.6.5/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/common.rb:88:in `create_response'
         2: from /Users/marcin/.gem/ruby/2.6.5/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/common.rb:88:in `new'
         1: from /Users/marcin/.gem/ruby/2.6.5/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/response.rb:34:in `initialize'
/Users/marcin/.gem/ruby/2.6.5/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/response.rb:72:in `assert_ok': chrome not reachable (Selenium::WebDriver::Error::WebDriverError)
  (Session info: chrome=81.0.4044.92)
  (Driver info: chromedriver=2.37.544337 (8c0344a12e552148c185f7d5117db1f28d6c9e85),platform=Mac OS X 10.15.2 x86_64)

As you can see from the above, my stack is:

  • Chrome 81.0.4044.92
  • Chromedriver 2.37.544337
  • MacOS 10.15.2 x86_64
  • Ruby 2.6.5
  • Selenium Webdriver gem 3.142.7

I can't provide the exact site on which I was able to replicate it because it appeared only after logging in. However, the code looked similar to this:

Solution 1:

Remove --single-process option.
Enabling this option means that the renderer and plugins will run in the same process as the browser. This may be useful if you're for instance running your code in a serverless function but in that case, you will probably not use standard chrome anyway.

Solution 2:

Use Chromium binary instead of Chrome.
Chromium is the open-source project, that the Chrome browser is based on. Google added more features to its' browser, as more media support, plugins, etc. You can read more here.
I used chromium version 84.0.4113.0 (Developer Build) (64-bit).
An interesting thing is that --single-process flag worked for Chromium, so it looks like Chrome renderer had more work to do.

Though I have not found the precise cause of this error, both of these solutions worked for me. I hope you will find it useful.

Discussion (0)