1

I have a very simple Selenium/Ruby script, with the following key line excerpts:

#!/usr/bin/env ruby
...
require 'selenium-webdriver'
...
options = Selenium::WebDriver::Chrome::Options.new
...
driver = Selenium::WebDriver.for :chrome, options: options
...
driver.quit

Quite simply, it just uses the operating system's (Ubuntu Linux) default offerings for Chrome and Chromedriver.

Every now and then, the Chrome automatically updates, and the Chromedriver does not, causing the script to start failing when run:

This version of ChromeDriver only supports Chrome version XX
Current browser version is YY with binary path /usr/bin/chromium-browser

It is trivial for me to manually update Chromedriver each time, but it is annoying.

What is the best practice way to automagically keep Chromedriver updated to match Chrome?

1
  • 2
    this is why the webdrivers gem was created. Enjoy! Sep 22, 2021 at 4:26

1 Answer 1

5

Generally in Python we use auto installer please see here, which is basically that auto install chromdriver against appropriate chrome browser version. We have the same functionality in Java-Selenium bindings as well using WebdriverManager.

Since you are asking for solely in ruby-Selenium bindings, I could find one Github repo, Please see here.

Run Selenium tests more easily with automatic installation and updates for all supported webdrivers.

  1. chromedriver
  2. geckodriver
  3. IEDriverServer
  4. msedgedriver

Works on macOS, Linux, Windows, and Windows Subsystem for Linux (WSL) v1 and v2. And do see the browser and OS specific notes at the bottom.

Usage

In your Gemfile:

gem 'webdrivers', '~> 4.0', require: false

In your project:

require 'webdrivers'

The drivers will now be automatically downloaded or updated when you launch a browser through Selenium.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.