{"record":{"id":"6acbce0758de3b76","repo":"SeleniumHQ/selenium","slug":"can-not-set-service-object-on-self-class","errorCode":null,"errorMessage":"Can not set :service object on #{self.class}","messagePattern":"Can not set :service object on #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/remote/driver.rb","lineNumber":53,"sourceCode":"                       **)\n          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\"","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/remote/driver.rb#L35-L71","documentation":"Raised by Remote::Driver#assert_arguments when a :service keyword argument is provided. Remote::Driver connects to an already-running Selenium Server or Grid endpoint, so it has no local driver service process to manage — :service is only meaningful for local driver subclasses (Chrome, Firefox, etc.) that spawn a browser driver executable.","triggerScenarios":"Calling Selenium::WebDriver.for(:remote, service: my_service, url: 'http://localhost:4444'). Passing a service object intended for a local driver into a Remote driver initialization. Copying local-driver config code into a Remote driver setup.","commonSituations":"Switching from a local driver (:chrome with service:) to a Remote/Grid setup and forgetting to remove the :service argument. Sharing a config hash across local and remote driver creation. Misunderstanding that :service manages the driver executable, not the remote endpoint.","solutions":["Remove the :service argument when using :remote; the remote server manages its own driver processes.","Use :url (or :client_config with server_url) to point at the remote endpoint instead.","If you need local driver behavior, use Selenium::WebDriver.for(:chrome, service: my_service) instead of :remote."],"exampleFix":"# before\ndriver = Selenium::WebDriver.for(:remote, service: service, url: 'http://grid:4444')\n\n# after\ndriver = Selenium::WebDriver.for(:remote, url: 'http://grid:4444')","handlingStrategy":"validation","validationCode":"# Validate config before driver creation:\nif driver_type == :remote && config.key?(:service)\n  raise ArgumentError, ':service is not valid for :remote driver; use :url instead'\nend","typeGuard":"def remote_compatible_config?(config)\n  !config.key?(:service)\nend","tryCatchPattern":"begin\n  Selenium::WebDriver.for(:remote, **config)\nrescue ArgumentError => e\n  config.delete(:service) if e.message.include?('service')\n  Selenium::WebDriver.for(:remote, **config)\nend","preventionTips":["Keep remote and local driver config hashes separate.","Document which kwargs apply to :remote vs local drivers.","When switching driver types, audit the config hash for driver-specific keys."],"tags":["argument-error","remote-driver","service","config-mistake"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}