{"record":{"id":"2750f926002ac6a5","repo":"SeleniumHQ/selenium","slug":"cannot-use-both-http-client-and-client-config-2750f9","errorCode":null,"errorMessage":"Cannot use both :http_client and :client_config","messagePattern":"Cannot use both :http_client and :client_config","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/remote/driver.rb","lineNumber":54,"sourceCode":"          assert_arguments(service, url, http_client, client_config)\n\n          caps = process_options(options, capabilities)\n          http_client ||= Remote::Http::Default.new(client_config: client_config)\n          server_url = url || client_config&.server_url || \"http://#{Platform.localhost}:4444/wd/hub\"\n          http_client.server_url = server_url\n          caps['se:remoteUrl'] = server_url.to_s.chomp('/')\n          super(caps: caps, http_client: http_client, **)\n          @bridge.file_detector = ->((filename, *)) { File.exist?(filename) && filename.to_s }\n          command_list = @bridge.command_list\n          @bridge.extend(WebDriver::Remote::Features)\n          @bridge.add_commands(command_list)\n        end\n\n        private\n\n        def assert_arguments(service, url, http_client, client_config)\n          raise ArgumentError, \"Can not set :service object on #{self.class}\" if service\n          raise ArgumentError, 'Cannot use both :http_client and :client_config' if http_client && client_config\n          raise ArgumentError, 'Cannot use both :url and a ClientConfig#server_url' if url && client_config&.server_url\n        end\n\n        def devtools_url\n          capabilities['se:cdp']\n        end\n\n        def devtools_version\n          cdp_version = capabilities['se:cdpVersion']&.split('.')&.first\n          raise Error::WebDriverError, 'DevTools is not supported by the Remote Server' unless cdp_version\n\n          Integer(cdp_version)\n        end\n\n        def process_options(options, capabilities)\n          if options && capabilities\n            msg = \"Don't use both :options and :capabilities when initializing #{self.class}, prefer :options\"\n            raise ArgumentError, msg","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/remote/driver.rb#L36-L72","documentation":"Raised by Remote::Driver#assert_arguments when both :http_client and :client_config keyword arguments are provided simultaneously. The driver can only derive its HTTP transport from one source: either a pre-built http_client object or a ClientConfig that the driver uses to build one internally — supplying both creates an ambiguous, conflicting configuration.","triggerScenarios":"Calling Selenium::WebDriver.for(:remote, url: url, http_client: my_client, client_config: config). Reusing a shared config hash that includes client_config and also passing an explicit http_client. Migrating from http_client to client_config without removing the old argument.","commonSituations":"Gradual migration from the legacy :http_client API to the newer :client_config API where both end up in the call. Centralized config builders that set both defensively. Copying code snippets from different documentation versions.","solutions":["Choose one HTTP configuration method: pass :client_config only, or :http_client only.","If you have a ClientConfig and need custom HTTP behavior, let the driver build the client from client_config rather than also passing http_client.","Audit shared config hashes to ensure only one of the two keys is present before driver creation."],"exampleFix":"# before\ndriver = Selenium::WebDriver.for(:remote,\n  url: url, http_client: Selenium::WebDriver::Remote::Http::Default.new,\n  client_config: Selenium::WebDriver::Remote::ClientConfig.new(server_url: url))\n\n# after\ndriver = Selenium::WebDriver.for(:remote,\n  client_config: Selenium::WebDriver::Remote::ClientConfig.new(server_url: url, read_timeout: 120))","handlingStrategy":"validation","validationCode":"# Ensure only one HTTP config source:\nif config[:http_client] && config[:client_config]\n  raise ArgumentError, 'Pass either :http_client or :client_config, not both'\nend","typeGuard":"def single_http_config?(config)\n  !(config[:http_client] && config[:client_config])\nend","tryCatchPattern":"begin\n  Selenium::WebDriver.for(:remote, **config)\nrescue ArgumentError => e\n  config.delete(:http_client) if e.message.include?('http_client')\n  Selenium::WebDriver.for(:remote, **config)\nend","preventionTips":["Standardize on :client_config for new code; remove legacy :http_client usage.","Audit shared config builders for both keys before driver creation.","Document the migration path from http_client to client_config in your codebase."],"tags":["argument-error","remote-driver","http-client","config-mistake"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}