Heads Up: Selenium 4 uses a binary to determine the chromedriver

Posted . Visible to the public.

I recently stumbled over a problem that my feature tests broke in CI because of a mismatching chromedriver version.

In this specific project we have a fixed Chromium version in a Debian 12 environment instead of Chrome. The tests however used a recent chrome version instead.

$ chromedriver --version
ChromeDriver 117.0.5938.149 (e3344ddefa12e60436fa28c81cf207c1afb4d0a9-refs/branch-heads/5938@{#1539})
$ chromium --version
Chromium 117.0.5938.149 built on Debian 12.1, running on Debian 12.1

> WARN Selenium [:selenium_manager] The chromedriver version (117.0.5938.149) detected in PATH at /usr/bin/chromedriver
might not be compatible with the detected chrome version (119.0.6045.105);
currently, chromedriver 119.0.6045.105 is recommended for chrome 119.*, so it is advised to delete the driver in PATH and retry 

It turned out that Selenium Webdriver 4 uses a binary called selenium-manager to determine the chromedriver, which probably also downloads Google Chrome for Testing Show archive.org snapshot if none is found on the system.

I worked around this behavior by setting the path to the binary in the selenium initializer

Capybara.register_driver :selenium do |app|
  additional_options = {}
  
  if gitlab_ci?
    additional_options[:binary] = `which chromium`.strip.presence
  end

  options = Selenium::WebDriver::Options.chrome(**additional_options)
end

Note

You can see the request when you turn off your network connection

WARN Selenium [:selenium_manager] Exception managing chrome: 
error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json): 
error trying to connect: dns error: failed to lookup address information: Try again
Florian Leinsinger
Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Florian Leinsinger to makandra dev (2023-11-03 12:50)