SeleniumHQ/selenium · error · Error::WebDriverError
could not find extension at #{path.inspect}
Error message
could not find extension at #{path.inspect} What it means
The deprecated Chromium::Profile#add_extension (Chrome::Profile / Edge::Profile) raises Error::WebDriverError when no regular file exists at the given path. Profile-based extension loading is deprecated in favor of Options#add_extension; the same file-existence check applies.
Source
Thrown at rb/lib/selenium/webdriver/chromium/profile.rb:44
class Profile
include ProfileHelper
def initialize(model = nil)
WebDriver.logger.deprecate(
'Chromium::Profile (including Chrome::Profile and Edge::Profile)',
"Options#add_argument('--user-data-dir=...'), Options#add_preference, and Options#add_extension",
id: :chromium_profile
)
@model = verify_model(model)
@extensions = []
@encoded_extensions = []
@directory = nil
end
def add_extension(path)
raise Error::WebDriverError, "could not find extension at #{path.inspect}" unless File.file?(path)
@extensions << path
end
def add_encoded_extension(encoded)
@encoded_extensions << encoded
end
def directory
@directory || layout_on_disk
end
#
# Set a preference in the profile.
#
# See https://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/pref_names.cc
#
View on GitHub (pinned to aa36b38e69)
Solutions
- Migrate to Options#add_extension (the supported API): options.add_extension(path).
- Pass an absolute path to an existing .crx file.
- Verify the file exists with File.file?(path) before calling.
- Heed the :chromium_profile deprecation warning and switch to Options-based config.
Example fix
// before
profile = Selenium::WebDriver::Chrome::Profile.new
profile.add_extension('ext.crx')
// after
options = Selenium::WebDriver::Chrome::Options.new
options.add_extension(File.expand_path('ext.crx', __dir__)) Defensive patterns
Strategy: validation
Validate before calling
raise 'migrate to Options' if defined?(profile) # Use the supported API: options.add_extension(path) if File.file?(path) && File.extname(path) == '.crx'
Type guard
def valid_extension_path?(path)
File.file?(path) && File.extname(path).casecmp?('.crx')
end Try / catch
begin profile.add_extension(path) rescue Selenium::WebDriver::Error::WebDriverError => e raise unless e.message =~ /could not find extension/ options.add_extension(File.expand_path(path, __dir__)) end
Prevention
- Migrate off Chromium::Profile to Options-based configuration.
- Use absolute .crx paths and validate existence before calling.
- Watch for the :chromium_profile deprecation warning and act on it.
When it happens
Trigger: Calling profile.add_extension(path) on a Chromium::Profile/Chrome::Profile/Edge::Profile where File.file?(path) is false.
Common situations: Using the old Profile API instead of Options, relative path issues, missing .crx at runtime, following outdated examples.
Related errors
- could not find extension at #{path.inspect}
- Path to the extension doesn't exist
- #{model}
- argument can not be null
- Port needs to be an integer
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/ff5372fea7fce289.
Report an issue: GitHub.