SeleniumHQ/selenium · error · ArgumentError
Cannot use both :http_client and :client_config
Error message
Cannot use both :http_client and :client_config
What it means
A local driver accepts HTTP configuration through either an :http_client object or a :client_config object, but not both at once. They are alternative, mutually exclusive ways to configure the HTTP transport to the driver service. Passing both raises ArgumentError.
Source
Thrown at rb/lib/selenium/webdriver/common/local_driver.rb:65
unless options.is_a?(default_options.class)
raise ArgumentError, ":options must be an instance of #{default_options.class}"
end
finder = WebDriver::DriverFinder.new(options, service)
options.binary = finder.browser_path if options.respond_to?(:binary) && finder.browser_path?
service.executable_path = finder.driver_path
options.browser_version = nil if options.respond_to?(:binary) && options.binary
options.as_json
end
private
def assert_local_arguments(url, http_client, client_config)
if url || client_config&.server_url
raise ArgumentError, "Can't set the server URL for #{self.class}; the service provides it"
elsif http_client && client_config
raise ArgumentError, 'Cannot use both :http_client and :client_config'
end
end
end
end
end
View on GitHub (pinned to aa36b38e69)
Solutions
- Choose one mechanism: pass only :http_client or only :client_config.
- If you need timeouts/URL settings, encode them in the ClientConfig and drop the http_client argument.
- If you have a custom HTTP client subclass, pass it via :http_client alone.
Example fix
# before driver = Selenium::WebDriver.for(:chrome, http_client: client, client_config: config) # after driver = Selenium::WebDriver.for(:chrome, client_config: config)
Defensive patterns
Strategy: validation
Validate before calling
raise ArgumentError, 'pass either http_client or client_config, not both' if http_client && client_config
Try / catch
begin
Selenium::WebDriver.for(:chrome, http_client: hc, client_config: cc)
rescue ArgumentError => e
raise unless e.message.include?('http_client and :client_config')
Selenium::WebDriver.for(:chrome, client_config: cc)
end Prevention
- Decide on a single HTTP configuration mechanism for the whole project.
- When migrating from http_client to client_config, remove the old argument.
- Validate the options hash does not contain both keys before driver creation.
When it happens
Trigger: Calling Selenium::WebDriver.for(:chrome, http_client: client, client_config: config). Building a ClientConfig for timeouts and also passing a custom Http::Default client.
Common situations: Gradually migrating from http_client-based configuration to client_config and leaving both in the hash. Merging two configuration sources without deduplication.
Related errors
- Can't set the server URL for #{self.class}; the service prov
- :options must be an instance of #{default_options.class}
- incompatible proxy type #{type.inspect} (already set to #{@t
- invalid port: #{@port}
- invalid port: #{@port}
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/00cd6bbdad329a3e.
Report an issue: GitHub.