I was surprised when a Capybara test that's been running fine for weeks, suddenly threw this error:
Selenium::WebDriver::Error::SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 131 Current browser version is 133.0.6943.54
I think my local Chrome instance updated itself, because this error indicates that chromedriver has gotten out of sync with the local version of Google Chrome.
As an aside, I run my CI locally, as DHH and crew at 37signals have recently begun doing. Part of running the signoff script includes running our E2E tests locally against a locally-installed version of Google Chrome, rather than something version-pinned in a ci.yml file. This does slightly increase the maintenance burden, but the trade-offs are worth it for this particular project.
There were quite a few, not-so-obvious steps to fix the version mismatch. So I wrote a tiny bash script to automate this process which will inevitably bite me again in the future:
# Purpose: # When using chromedriver for anything (like capybara tests in Rails), you have this annoying # dance where you need to keep chromedriver up-to-date with Chrome itself. This script just # aims to make life a bit easier here. # First kill existing chromedriver, if any ps auwwx | ag chromedriver | ag -v ag | awk '{ print $2 }' | xargs kill # Update brew itself, which pulls latest cask references brew update brew upgrade chromedriver # Get the installed version and binary path from brew info path_info=$(brew info --json=v2 --casks chromedriver | jq -r ' .casks[0] | [.installed, .artifacts[0].binary[0]] | @tsv ') # Split the output into version and binary path read -r version binary_path <<< "$path_info" # Construct the full path full_path="/opt/homebrew/Caskroom/chromedriver/$version/$binary_path" # Turn off Apple's quarantine otherwise it will not let you run the new version of chromedriver echo xattr -d com.apple.quarantine "$full_path"
🙌🏻 🎉