{"record":{"id":"f54839d2ef104a70","repo":"SeleniumHQ/selenium","slug":"safari-does-not-support-options-that-are-not-names","errorCode":null,"errorMessage":"Safari does not support options that are not namespaced","messagePattern":"Safari does not support options that are not namespaced","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/safari/options.rb","lineNumber":35,"sourceCode":"# specific language governing permissions and limitations\n# under the License.\n\nmodule Selenium\n  module WebDriver\n    module Safari\n      class Options < WebDriver::Options\n        attr_accessor :options\n\n        # @see https://developer.apple.com/documentation/webkit/about_webdriver_for_safari\n        CAPABILITIES = {automatic_inspection: 'safari:automaticInspection',\n                        automatic_profiling: 'safari:automaticProfiling',\n                        experimental_web_socket_url: 'safari:experimentalWebSocketUrl'}.freeze\n        BROWSER = 'safari'\n        TECHNOLOGY_PREVIEW = 'Safari Technology Preview'\n\n        def add_option(name, value = nil)\n          key = name.is_a?(Hash) ? name.keys.first : name\n          raise ArgumentError, 'Safari does not support options that are not namespaced' unless key.to_s.include?(':')\n\n          super\n        end\n\n        def browser_name=(value)\n          @options[:browser_name] = value\n        end\n\n        def browser_name\n          @options[:browser_name] = Safari.technology_preview? ? TECHNOLOGY_PREVIEW : BROWSER\n        end\n\n        #\n        # Enables WebDriver BiDi for Safari, which also requires the experimental capability, and\n        # warns that Safari's BiDi support is experimental.\n        #\n        # @return [Boolean]\n        #","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/safari/options.rb#L17-L53","documentation":"Safari::Options#add_option overrides the base Options#add_option to enforce that every capability key passed to safaridriver must be vendor-namespaced (contain a ':'). safaridriver rejects non-namespaced (W3C-standard) custom options at the protocol level, so the Ruby binding fails fast in Ruby rather than letting a malformed session request reach Apple's driver. Only the 'safari:' prefix and the predefined CAPABILITIES are accepted.","triggerScenarios":"Calling Selenium::WebDriver::Safari::Options#add_option with a bare Symbol/String key such as add_option(:detach, true), add_option('myOpt', 1), or add_option(foo: 1) where the key has no colon. Any key whose to_s does not include ':' triggers it.","commonSituations":"Copy-pasting Chrome/Firefox option code into a Safari test; using a generic helper that calls add_option across all browser Options classes with the same unprefixed key; assuming Safari accepts the same W3C extension keys as Chrome.","solutions":["Prefix the key with a vendor namespace, e.g. add_option('myVendor:myOpt', value) or use a namespaced Symbol like add_option(:'custom:flag', true).","For built-in Safari capabilities use the predefined accessors (automatic_inspection:, automatic_profiling:, experimental_web_socket_url:) instead of add_option.","Branch your option-setting helper per browser so Safari keys always carry a ':' namespace."],"exampleFix":"# before\noptions = Selenium::WebDriver::Safari::Options.new\noptions.add_option(:detach, true)\n\n# after\noptions.add_option('custom:detach', true)","handlingStrategy":"validation","validationCode":"def namespaced?(key)\n  k = key.is_a?(Hash) ? key.keys.first : key\n  k.to_s.include?(':')\nend\n\nopt_name = :detach\nif namespaced?(opt_name)\n  safari_options.add_option(opt_name, true)\nelse\n  safari_options.add_option(\"custom:#{opt_name}\", true)\nend","typeGuard":"def safari_option_key?(key)\n  k = key.is_a?(Hash) ? key.keys.first : key\n  k.respond_to?(:to_s) && k.to_s.include?(':')\nend","tryCatchPattern":"begin\n  safari_options.add_option(name, value)\nrescue ArgumentError => e\n  raise unless e.message.include?('not namespaced')\n  safari_options.add_option(\"vendor:#{name}\", value)\nend","preventionTips":["Centralize option-setting in a per-browser helper that always prefixes Safari keys with a vendor namespace.","Prefer Safari::Options CAPABILITIES accessors (automatic_inspection etc.) over add_option for known Safari features.","Unit-test your options builder against Safari::Options to catch missing namespaces early."],"tags":["safari","capabilities","validation","argument-error","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}