SeleniumHQ/selenium · error · Selenium::WebDriver::Error::WebDriverError
Could not find a valid devtools version; use a more recent v
Error message
Could not find a valid devtools version; use a more recent version of selenium-devtools gem
What it means
Raised by Selenium::Devtools.load_older_version (devtools.rb) after both v-1 and v-2 fallback requires fail with LoadError. It means the installed selenium-devtools gem has no protocol module matching the browser's CDP version within two major versions. The fix is to install a newer selenium-devtools gem.
Source
Thrown at rb/lib/selenium/devtools.rb:42
def load_version
require "selenium/devtools/v#{@version}"
rescue LoadError
WebDriver.logger.warn "Could not load selenium-devtools v#{@version}. Trying older versions.",
id: :devtools
load_older_version
end
private
# Try to load up to 2 versions back
def load_older_version
load_old_version(@version - 1)
rescue LoadError
begin
load_old_version(@version - 2)
rescue LoadError
raise WebDriver::Error::WebDriverError,
'Could not find a valid devtools version; use a more recent version of selenium-devtools gem'
end
end
def load_old_version(version)
require "selenium/devtools/v#{version}"
self.version = version
msg = "Using selenium-devtools version v#{version}, some features may not work as expected."
WebDriver.logger.warn msg, id: :devtools
end
end
end # DevTools
end # Selenium
View on GitHub (pinned to aa36b38e69)
Solutions
- Update the selenium-devtools gem: gem install selenium-devtools or bundle update selenium-devtools.
- Keep selenium-webdriver and selenium-devtools on the same release line.
- Downgrade the browser to one whose CDP version the gem supports, if upgrading the gem is not possible.
Example fix
# before # Gemfile.lock pins selenium-devtools 0.114.0 with Chrome 131 # after gem 'selenium-devtools', '~> 0.131' # then: bundle update selenium-devtools
Defensive patterns
Strategy: fallback
Validate before calling
require 'rubygems' begin gem 'selenium-devtools', '>= ' + @version.to_s rescue Gem::MissingSpecVersionError warn 'selenium-devtools too old for CDP v' + @version.to_s + '; upgrade the gem' end
Try / catch
begin
Selenium::DevTools.load_version
rescue Selenium::WebDriver::Error::WebDriverError => e
raise unless e.message.include?('valid devtools version')
system('gem install selenium-devtools') or
raise 'Install a newer selenium-devtools gem to match your browser CDP version'
end Prevention
- Keep selenium-devtools and selenium-webdriver on the same release line.
- Run bundle update selenium-devtools when upgrading the browser.
- Pin the browser to a CDP version the installed gem supports if you cannot upgrade.
When it happens
Trigger: load_version fails to require selenium/devtools/v{@version}; load_older_version tries v-1, then v-2, both raise LoadError, so it raises WebDriver::Error::WebDriverError (devtools.rb:36-45).
Common situations: A very new Chrome/Edge whose CDP version is more than 2 ahead of the installed gem; an outdated selenium-devtools gem pinned in a Gemfile/lockfile; major version drift between selenium-webdriver and selenium-devtools.
Related errors
- CDP devtools module not loaded. Call import_devtools() first
- CDP version not found in capabilities
- Unable to find url to connect to from capabilities
- CDP module not loaded
- command_executor must be a RemoteConnection instance for CDP
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/b96a58d390a617d4.
Report an issue: GitHub.