Updating chromedriver without updating main image in CircleCI
TL:DR: you can update chrome and chromedriver using browser-tools orb without changing your main image
Why we needed to update chromedriver
We were getting lots of random JS errors in our Ruby on Rails Capybara feature tests which we managed to nail down to being due to using an old version of chromedriver. About one in ten test runs a huge number of JS tests would run wit this error.
Digging in we could see this error
Errno::ECONNREFUSED:
Failed to open TCP connection to 127.0.0.1:9515 (Connection refused - connect(2) for "127.0.0.1" port 9515)
# ./spec/features/payments_feature_spec.rb:30:in `block (3 levels) in <main>'
# ------------------
# --- Caused by: ---
# Errno::ECONNREFUSED:
# Connection refused - connect(2) for "127.0.0.1" port 9515
# ./spec/features/payments_feature_spec.rb:30:in `block (3 levels) in <main>' 113.2) Failure/Error:
raise e, "Failed to open TCP connection to " +
"#{conn_address}:#{conn_port} (#{e.message})"
Some googling led us to thinking it was the chromedriver version.
Finding out chromedriver version in CircleCi
I was able to find out the chromedriver version by pulling the docker image we use in our CircleCI config and checking the version
$ docker pull circleci/ruby:2.6.5-node-browsers
$ docker images
$ docker run <img id> chromedriver -v
Upgrading our ruby version to 2.6.6 would allows us to upgrade to the next docker image circleci/ruby:2.6.6-node-browsers
which runs chromedriver 87.
However we’d also need to update our node version from 12.x to 14.x which would involve lots of node_module updates which I was hoping to avoid.
browser-tools orb to the rescue
CircleCI has orbs which help you with things like this. They save you writing tons more config. The browser-tools orb had ways of installing chromedriver to replace the current version.
To add it we add the orb to the top of our file and then we include installing chrome and chromedriver to the steps