{"record":{"id":"8f1e2c4dd2c3a129","repo":"SeleniumHQ/selenium","slug":"can-t-set-the-server-url-for-self-class-the-se","errorCode":null,"errorMessage":"Can't set the server URL for #{self.class}; the service provides it","messagePattern":"Can't set the server URL for #(.+?); the service provides it","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/common/local_driver.rb","lineNumber":63,"sourceCode":"        default_options = Options.send(browser)\n        options ||= default_options\n\n        unless options.is_a?(default_options.class)\n          raise ArgumentError, \":options must be an instance of #{default_options.class}\"\n        end\n\n        finder = WebDriver::DriverFinder.new(options, service)\n        options.binary = finder.browser_path if options.respond_to?(:binary) && finder.browser_path?\n        service.executable_path = finder.driver_path\n        options.browser_version = nil if options.respond_to?(:binary) && options.binary\n        options.as_json\n      end\n\n      private\n\n      def assert_local_arguments(url, http_client, client_config)\n        if url || client_config&.server_url\n          raise ArgumentError, \"Can't set the server URL for #{self.class}; the service provides it\"\n        elsif http_client && client_config\n          raise ArgumentError, 'Cannot use both :http_client and :client_config'\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":45,"sourceCodeEnd":71,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/local_driver.rb#L45-L71","documentation":"Local drivers (Chrome, Firefox, Edge, etc.) launch their own driver service process and derive the server URL from that service; the URL cannot be supplied by the caller. assert_local_arguments raises ArgumentError if a :url is provided or if a client_config with a server_url is set. To connect to an already-running remote endpoint, use the :remote driver instead.","triggerScenarios":"Passing url: 'http://localhost:9515' to Selenium::WebDriver.for(:chrome, url: ...). Constructing a ClientConfig with server_url and passing it to a local browser driver. Reusing a remote-driver initialization block for a local driver.","commonSituations":"Migrating code from a remote setup and forgetting to remove the explicit URL. Wanting to attach to a manually-started driver service instead of letting Selenium manage it.","solutions":["Remove the :url argument when using a local driver; Selenium starts and addresses the service for you.","To connect to a pre-existing driver service, use Selenium::WebDriver.for(:remote, url: 'http://host:port', options: opts).","If using client_config, do not set server_url on it for a local driver."],"exampleFix":"# before\ndriver = Selenium::WebDriver.for(:chrome, url: 'http://localhost:9515')\n\n# after (local)\ndriver = Selenium::WebDriver.for(:chrome)\n# or (remote to existing service)\ndriver = Selenium::WebDriver.for(:remote, url: 'http://localhost:9515', options: Selenium::WebDriver::Chrome::Options.new)","handlingStrategy":"validation","validationCode":"raise ArgumentError, 'do not pass :url to a local driver' if url && local_browser?","typeGuard":null,"tryCatchPattern":"begin\n  Selenium::WebDriver.for(:chrome)\nrescue ArgumentError => e\n  raise unless e.message.include?('server URL')\n  Selenium::WebDriver.for(:remote, url: url, options: opts)\nend","preventionTips":["For local drivers, never pass :url or a client_config.server_url.","Use the :remote driver when you need to connect to an existing endpoint.","Centralize driver creation so local vs remote intent is explicit."],"tags":["ruby","driver-init","local-driver","configuration"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}