Managing chrome versions for selenium

Posted . Visible to the public.

Currently we often use geordi Show archive.org snapshot to run cucumber and rspec tests. Geordi takes care of installing a matching chromedriver for the installed google-chrome binary. The google-chrome binary is managed by apt.

Another approach is to use the Selenium Manager Show archive.org snapshot for installing and using the correct browser versions for you. Here is the setup you need for your integration tests:

Capybara.register_driver :chrome do |app|
  options = Selenium::WebDriver::Chrome::Options.new
  options.browser_version = '138.0.7204.183'

  Capybara::Selenium::Driver.new(app, browser: :chrome, options:)
end

The first time you run a test with capybara a matching chrome and chromedriver version is installed to the cache ~/.cache/selenium/. You will notice a delay of ~1 minute.

CI

Optionally you can use the Selenium Manager for installing a matching chrome and chromedriver in your docker image (instead of puppeteer). Here is an extract on how the setup (with rbenv) might look like:

# [...]

RUN git clone --depth=1 https://github.com/rbenv/rbenv.git $HOME/.rbenv \
  && git clone --depth=1 https://github.com/rbenv/ruby-build.git $HOME/.rbenv/plugins/ruby-build \
  && echo 'eval "$(/root/.rbenv/bin/rbenv init - bash)"' >> $HOME/.bash_profile \
  && bash -l -c 'rbenv install 3.4.5 && rbenv global 3.4.5'
RUN bash -l -c 'gem install bundler:2.4.13'
RUN bash -l -c 'bundle config --global build.nokogiri --use-system-libraries'
RUN bash -l -c 'gem install selenium-webdriver --version 4.34.0 && /root/.rbenv/versions/3.4.5/lib/ruby/gems/3.4.0/gems/selenium-webdriver-4.34.0/bin/linux/selenium-manager --browser=chrome --browser-version=138.0.7204.183'

# [...]
Last edit
Emanuel
License
Source code in this card is licensed under the MIT License.
Posted by Emanuel to makandra dev (2025-08-06 14:04)