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?