Read more

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

Florian Leinsinger
November 03, 2023Software engineer at makandra GmbH

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

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

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
Posted by Florian Leinsinger to makandra dev (2023-11-03 13:50)