{"record":{"id":"c29c0eadb9ebace1","repo":"SeleniumHQ/selenium","slug":"self-class-needs-options-to-be-set","errorCode":null,"errorMessage":"#{self.class} needs :options to be set","messagePattern":"#(.+?) needs :options to be set","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/remote/driver.rb","lineNumber":74,"sourceCode":"        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\n          elsif options.nil? && capabilities.nil?\n            raise ArgumentError, \"#{self.class} needs :options to be set\"\n          end\n          options ? options.as_json : generate_capabilities(capabilities)\n        end\n\n        def generate_capabilities(capabilities)\n          Array(capabilities).map { |cap|\n            if cap.is_a? Symbol\n              cap = WebDriver::Options.send(cap)\n            elsif !cap.respond_to? :as_json\n              msg = \":capabilities parameter only accepts objects responding to #as_json which #{cap.class} does not\"\n              raise ArgumentError, msg\n            end\n            cap.as_json\n          }.inject(:merge)\n        end\n      end # Driver\n    end # Remote\n  end # WebDriver","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/remote/driver.rb#L56-L92","documentation":"Raised by Remote::Driver#process_options when neither :options nor :capabilities is provided to the driver constructor. Remote::Driver requires at least one to know what browser session to request from the server — without it, the W3C new-session request would have no 'capabilities' field and every server would reject it.","triggerScenarios":"Calling Selenium::WebDriver.for(:remote, url: url) with no options or capabilities. Passing an empty hash or only :url/:http_client. A config builder that conditionally sets options but the condition evaluates to nil.","commonSituations":"Forgetting to specify browser options when switching from a local driver (which infers them from the driver type) to :remote. Nil-valued config keys being silently dropped by double-splat. Refactoring that moved options construction behind a conditional branch that wasn't taken.","solutions":["Provide an Options object: Selenium::WebDriver.for(:remote, url: url, options: Selenium::WebDriver::Options.chrome).","If using a dynamic browser name, build options conditionally but ensure the result is never nil: options = Selenium::WebDriver::Options.send(browser_name.to_sym).","Validate your config hash has a non-nil :options value before passing it to the driver constructor."],"exampleFix":"# before\ndriver = Selenium::WebDriver.for(:remote, url: url)\n\n# after\ndriver = Selenium::WebDriver.for(:remote, url: url,\n  options: Selenium::WebDriver::Options.chrome)","handlingStrategy":"validation","validationCode":"# Ensure options is non-nil:\nraise ArgumentError, ':options is required for :remote' unless config[:options] || config[:capabilities]\n# or set a default:\nconfig[:options] ||= Selenium::WebDriver::Options.chrome\nSelenium::WebDriver.for(:remote, **config)","typeGuard":"def has_session_config?(config)\n  !config[:options].nil? || !config[:capabilities].nil?\nend","tryCatchPattern":"begin\n  Selenium::WebDriver.for(:remote, **config)\nrescue ArgumentError => e\n  raise unless e.message.include?('needs :options')\n  Selenium::WebDriver.for(:remote, options: Selenium::WebDriver::Options.chrome, **config)\nend","preventionTips":["Always pass an explicit Options object to :remote driver creation.","Guard conditional options construction to never return nil.","Validate config hashes have a non-nil :options before driver creation."],"tags":["argument-error","remote-driver","options","missing-argument"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}