{"record":{"id":"27bcffde4cc818c3","repo":"SeleniumHQ/selenium","slug":"these-options-are-not-w3c-compliant-options","errorCode":null,"errorMessage":"These options are not w3c compliant: #{options}","messagePattern":"These options are not w3c compliant: #(.+?)","errorType":"exception","errorClass":"Error::WebDriverError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/common/options.rb","lineNumber":136,"sourceCode":"      alias eql? ==\n\n      #\n      # @api private\n      #\n\n      def as_json(*)\n        options = @options.dup\n\n        downloads = options.delete(:enable_downloads)\n        options['se:downloadsEnabled'] = downloads unless downloads.nil?\n        w3c_options = process_w3c_options(options)\n\n        browser_options = self.class::CAPABILITIES.each_with_object({}) do |(capability_alias, capability_name), hash|\n          capability_value = options.delete(capability_alias)\n          hash[capability_name] = capability_value unless capability_value.nil?\n        end\n\n        raise Error::WebDriverError, \"These options are not w3c compliant: #{options}\" unless options.empty?\n\n        browser_options = {self.class::KEY => browser_options} if defined?(self.class::KEY)\n\n        process_browser_options(browser_options)\n        generate_as_json(merge_browser_options(w3c_options, browser_options))\n      end\n\n      private\n\n      # Preserve a hand-built vendor options hash (e.g. passed through #add_option) by merging it\n      # with the binding's own, rather than letting one silently overwrite the other.\n      def merge_browser_options(w3c_options, browser_options)\n        w3c_options.merge(browser_options) do |_key, w3c_value, browser_value|\n          if w3c_value.is_a?(Hash) && browser_value.is_a?(Hash)\n            browser_value.merge(w3c_value)\n          else\n            browser_value\n          end","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/options.rb#L118-L154","documentation":"Options#as_json serializes capabilities for the W3C session. It first extracts known W3C options and registered vendor capabilities; any keys left over are treated as non-compliant and raise WebDriverError. Vendor-specific or experimental capabilities must be registered through add_option rather than passed as unrecognized constructor keys.","triggerScenarios":"Constructing Options.new(some_unknown_key: value) where the key is neither a W3C option nor a registered capability. Mutating options.options directly with an arbitrary key. Typo-ing a capability name so it is not consumed by the CAPABILITIES map.","commonSituations":"Trying to set a browser-specific flag (e.g. a Chrome experimental option) via the constructor hash instead of add_option. Copying a capability name with a typo or wrong casing. Passing a Hash of capabilities that includes unsupported entries.","solutions":["Register vendor/experimental options via options.add_option(:detach, true) so they are preserved through serialization.","Use the documented accessor methods (e.g. options.page_load_strategy=) for known capabilities.","Inspect Options::W3C_OPTIONS and the class CAPABILITIES constant to confirm which keys are accepted in the constructor.","Remove any unrecognized keys from the constructor hash and re-add them with add_option."],"exampleFix":"# before\noptions = Selenium::WebDriver::Chrome::Options.new(detach: true)\n\n# after\noptions = Selenium::WebDriver::Chrome::Options.new\noptions.add_option(:detach, true)","handlingStrategy":"validation","validationCode":"known = (Selenium::WebDriver::Options::W3C_OPTIONS + options.class::CAPABILITIES.keys)\nunknown = opts.keys - known\nraise ArgumentError, \"unknown options: #{unknown.inspect}\" unless unknown.empty?","typeGuard":"def w3c_or_known?(options, key)\n  Selenium::WebDriver::Options::W3C_OPTIONS.include?(key) ||\n    options.class::CAPABILITIES.key?(key) || key.to_s.include?(':')\nend","tryCatchPattern":"begin\n  options.as_json\nrescue Selenium::WebDriver::Error::WebDriverError => e\n  raise unless e.message.include?('not w3c compliant')\n  # move unknown keys into add_option and retry\nend","preventionTips":["Use options.add_option(name, value) for any vendor or experimental capability.","Keep constructor arguments limited to documented W3C and browser-specific accessors.","Inspect Options::W3C_OPTIONS and the class CAPABILITIES constant to learn accepted keys."],"tags":["ruby","options","capabilities","w3c","serialization"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}