gopackgo90
Posts: 4
Joined: Fri Jul 27, 2018 5:15 pm

ChromeDriver "Message: chrome not reachable" in Buster

Fri Nov 29, 2019 2:42 am

After installing Buster, I came across a problem using Selenium with Chrome. This was not a problem in Stretch. Below is a sample Python script, steps to reproduce the problem, and the exact error message I am getting.

Sample Python script (test_script.py):

Code: Select all

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.headless = True
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver', options=options)
driver.implicitly_wait(30)

driver.get('https://www.google.com/')

try:
    driver.find_element_by_css_selector("input[name='q']")
finally:
    driver.quit()
Steps to recreate:
  1. Install a fresh Buster (I'm using a Raspberry Pi 4, not sure if the hardware matters)
  2. Install ChromeDriver

    Code: Select all

    sudo apt install chromium-chromedriver
  3. Setup a virtual environment for Python

    Code: Select all

    python3 -m venv selenium_test
  4. Activate the newly created virtual environment

    Code: Select all

    source selenium_test/bin/activate
  5. Install Selenium in the virtual environment

    Code: Select all

    pip install selenium
  6. Run the test script above

    Code: Select all

    python test_script.py
Running the above script results in the below error message:

Code: Select all

(selenium_test) [email protected]:~ $ python test_script.py 
Traceback (most recent call last):
  File "test_script.py", line 12, in <module>
    driver.find_element_by_css_selector("input[name='q']")
  File "/home/pi/selenium_test/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 598, in find_element_by_css_selector
    return self.find_element(by=By.CSS_SELECTOR, value=css_selector)
  File "/home/pi/selenium_test/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 978, in find_element
    'value': value})['value']
  File "/home/pi/selenium_test/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/home/pi/selenium_test/lib/python3.7/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
  (Session info: headless chrome=74.0.3729.157)
  (Driver info: chromedriver=74.0.3729.157 (7b16107ab85c5364cdcd0b2dea2539a1f2dc327a-refs/branch-heads/[email protected]{#998}),platform=Linux 4.19.75-v7l+ armv7l)
Does anyone know where I can submit a proper bug report for Raspbian? I noticed Debian Buster has a chromium-driver package for Buster that is version 78.0.3904.108. Can Raspbian update to this newer version as well? Maybe that would fix it in Raspbian?

There are a few relevant web results on Stack Overflow/GitHub:

gopackgo90
Posts: 4
Joined: Fri Jul 27, 2018 5:15 pm

Re: ChromeDriver "Message: chrome not reachable" in Buster

Mon Dec 02, 2019 4:45 am

I also have a Java example that doesn't work/has the same error as Python.

Sample Java class (JavaTest.java):

Code: Select all

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class JavaTest {

  public static void main(String[] args) {
    System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");

    ChromeOptions options = new ChromeOptions();
    options.addArguments("--headless");
    WebDriver driver = new ChromeDriver(options);
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    driver.get("https://www.google.com/");
    try {
        driver.findElement(By.cssSelector("input[name='q']"));
    } finally {
        driver.quit();
    }
  }
}
Steps to recreate:
  1. Install a fresh Buster (I'm using a Raspberry Pi 4, not sure if the hardware matters)
  2. Install ChromeDriver

    Code: Select all

    sudo apt install chromium-chromedriver
  3. Download and unzip the Selenium client

    Code: Select all

    wget https://selenium-release.storage.googleapis.com/3.141/selenium-java-3.141.59.zip -P selenium-java-3.141.59
    unzip selenium-java-3.141.59/selenium-java-3.141.59.zip -d selenium-java-3.141.59
    
  4. Compile and run the Java code above

    Code: Select all

    javac -cp ".:/home/pi/selenium-java-3.141.59/client-combined-3.141.59.jar:/home/pi/selenium-java-3.141.59/libs/*" JavaTest.java
    java -cp ".:/home/pi/selenium-java-3.141.59/client-combined-3.141.59.jar:/home/pi/selenium-java-3.141.59/libs/*" JavaTest
    
Running the above code results in the below error message:

Code: Select all

[email protected]:~ $ java -cp ".:/home/pi/selenium-java-3.141.59/client-combined-3.141.59.jar:/home/pi/selenium-java-3.141.59/libs/*" JavaTest
Starting ChromeDriver 74.0.3729.157 (7b16107ab85c5364cdcd0b2dea2539a1f2dc327a-refs/branch-heads/[email protected]{#998}) on port 1221
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
 --disable-quic --enable-tcp-fast-open --ppapi-flash-path=/usr/lib/chromium-browser/libpepflashplayer.so --ppapi-flash-args=enable_stagevideo_auto=0 --ppapi-flash-version=
Dec 01, 2019 10:43:37 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
[1575261818.333][SEVERE]: Unable to receive message from renderer
Exception in thread "main" org.openqa.selenium.WebDriverException: chrome not reachable
  (Session info: headless chrome=74.0.3729.157)
  (Driver info: chromedriver=74.0.3729.157 (7b16107ab85c5364cdcd0b2dea2539a1f2dc327a-refs/branch-heads/[email protected]{#998}),platform=Linux 4.19.75-v7l+ armv7l) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'raspberrypi', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'arm', os.version: '4.19.75-v7l+', java.version: '11.0.5'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 74.0.3729.157 (7b16107ab85c..., userDataDir: /tmp/.org.chromium.Chromium...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:34365}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 74.0.3729.157, webStorageEnabled: true}
Session ID: c83b71b528d91ebe8b10b9d9c1dcce92
*** Element info: {Using=css selector, value=input[name='q']}
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
	at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
	at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
	at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
	at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:420)
	at org.openqa.selenium.By$ByCssSelector.findElement(By.java:431)
	at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
	at JavaTest.main(JavaTest.java:18)
This also has the "WebDriverException: chrome not reachable" error, so the problem doesn't appear to be language specific. Running the same code in Raspbian Stretch does not have this issue.

gopackgo90
Posts: 4
Joined: Fri Jul 27, 2018 5:15 pm

Re: ChromeDriver "Message: chrome not reachable" in Buster

Tue Dec 03, 2019 1:34 am

Update, this looks to be an issue with the Chrome version that is included with Raspbian Buster. I may have come across a workaround by adding the "--disable-features=VizDisplayCompositor" option. It is helpful to enable verbose logging for the chromedriver to get more useful hints on what is going wrong with the ChromeDriver.

Python:

Code: Select all

options.add_argument('--disable-features=VizDisplayCompositor')
Java:

Code: Select all

options.addArguments("--disable-features=VizDisplayCompositor");
See also:
https://stackoverflow.com/a/55371396/11678788
https://github.com/puppeteer/puppeteer/ ... -480210268

Return to “Raspbian”