1

I'm want to run Selenium tests using Chromedriver on a Chromebook and I'm not able to get it to work.

Setup
I have crouton and chromebrew installed. chromebrew has packages for virtualenv and Python3.6, plus with pip install Selenium I got Selenium. From the ChromeDriver ChromeOS documentation I know the chromedriver is in /usr/local/chromedriver. Calling it:

chronos@localhost /usr/local/chromedriver $ chromedriver 
Starting ChromeDriver 2.24 on port 9515
Only local connections are allowed.

gives me the version and I only want to test localhost so I'm fine and have:

Versions:  
ChromiumOS 55.0.2883.100 (64-bit)  
Python 3.6  
Selenium bindings for Python 3.13.0  
Chromedriver 2.24  

I (think I) understand that the Chromedriver behaves like a server on port 9515 waiting for calls from test.py. I fiddled around until I got no more errors for missing chromedriver/permissions/etc.

Test File
My test file only contains:

from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')
chrome_options.binary_location = '/etc/chromium.exe'

driver = webdriver.Chrome('/usr/local/chromedriver/chromedriver', chrome_options=chrome_options)
driver.get("http://localhost:8000")

If I call python3 test.py or get("http://localhost:8000") nothing happens and on my python3 call, I eventually end up with:

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    driver = webdriver.Chrome('/usr/local/chromedriver/chromedriver', chrome_options=chrome_options)
  File "/usr/local/demo/venv/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
    desired_capabilities=desired_capabilities)
  File "/usr/local/demo/venv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 156, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/demo/venv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 251, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/demo/venv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 320, in execute
    self.error_handler.check_response(response)
  File "/usr/local/demo/venv/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: chrome not reachable
  (Driver info: chromedriver=2.24,platform=Linux 3.14.0 x86_64)

I also found this test script on the chromedriver documentation to run the chromedriver as a service with the same result as above:

import time

from selenium import webdriver
import selenium.webdriver.chrome.service as service

service = service.Service('/usr/local/chromedriver/chromedriver')
service.start()
capabilities = {'chrome.binary': '/etc/chromium.exe'}
driver = webdriver.Remote(service.service_url, capabilities)
driver.get('http://localhost:8000');
time.sleep(5) # Let the user actually see something!
driver.quit()

You'll see I swapped Chrome with custom Chromium in the capabilities. From chromedriver documentation and this SO answer this is the way to replace the default Chrome binary with a custom one.

I understand from this github issue that the problem could be that versions of components don't play nice with each other, but the Chromedriver documentation it points to doesn't really tell me where to start looking for which versions to try.

I think I have covered all cases except for incompatible versions, so question is, who can tell me which version of what can get this to run?

frequent
  • 27,643
  • 59
  • 181
  • 333
  • here we go: [compat matrix](https://stackoverflow.com/questions/41133391/which-chromedriver-chrome-browser-version-compatible-in-selenium-3) – frequent Jun 26 '18 at 20:39

1 Answers1

1

This error message...

selenium.common.exceptions.WebDriverException: Message: chrome not reachable

...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

There are numerous possibilities beyond this error as follows:

  • As you are on Linux OS while you mention the absolute path of the chromium binary you need to strip the extension i.e. .exe as follows:

    chrome_options.binary_location = '/etc/chromium'
    
  • While you initialize the Chrome browsing session you need to pass both the arguments chrome_options and executable_path as follows:

    driver = webdriver.Chrome(executable_path='/usr/local/chromedriver/chromedriver', chrome_options=chrome_options)
    
  • Just like regular Chrome Browser GA releases, Chrome Team does releases the ChromeDriver binaries with added/modified functionalities along with corrosponding supported Chrome Browser versions. You need to ensure that the chrome and chromedriver binaries which you are using are in sync following the Release Notes.

You can find a related discussion on versioning in Selenium for ChromeDriver and Chrome Browser

However, your main issue is the incompatibility between the version of the binaries you are using as follows:

  • You are using chromedriver=2.24
  • Release Notes of chromedriver=2.24 clearly mentions the following :

Supports Chrome v52-54

  • You are using chrome=55.0
  • Release Notes of ChromeDriver v2.27 clearly mentions the following :

Supports Chrome v54-56

So there is a clear mismatch between ChromeDriver v2.24 and Chrome Browser v55.0

Solution

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    ah, wow, thanks, I'll go through the list and report back if I can solve it – frequent Jun 27 '18 at 07:41
  • I'm not there yet - see my [follow-up question](https://askubuntu.com/questions/1050259/why-does-dpkg-l-show-my-library-is-in-folder-usr-share-doc-when-it-doesnt-exi) but upgrading Chrome (v62 is [best I can do currently](https://nayuos.nexedi.com/)) and chromedriver to compatible version brought me on track with missing libraries. Let's see if I can get it to work. I'll mark this one as correct, Thanks for helping – frequent Jun 27 '18 at 21:21