{"record":{"id":"86784fd018cd1648","repo":"SeleniumHQ/selenium","slug":"don-t-know-how-to-handle-kind-events","errorCode":null,"errorMessage":"Don't know how to handle #{kind} events","messagePattern":"Don't know how to handle #(.+?) events","errorType":"exception","errorClass":"Error::WebDriverError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb","lineNumber":60,"sourceCode":"        # @example Collect JavaScript exceptions\n        #   exceptions = []\n        #   driver.on_log_event(:exception) do |event|\n        #     exceptions.push(event)\n        #   end\n        #\n        # @example Collect DOM mutations\n        #   mutations = []\n        #   driver.on_log_event(:mutation) do |event|\n        #     mutations.push(event)\n        #   end\n        #\n        # @param [Symbol] kind :console, :exception or :mutation\n        # @param [#call] block which is called when event happens\n        # @yieldparam [DevTools::ConsoleEvent, DevTools::ExceptionEvent, DevTools::MutationEvent]\n        #\n\n        def on_log_event(kind, &block)\n          raise Error::WebDriverError, \"Don't know how to handle #{kind} events\" unless KINDS.include?(kind)\n\n          enabled = log_listeners[kind].any?\n          log_listeners[kind] << block\n          return if enabled\n\n          devtools.runtime.enable\n          __send__(:\"log_#{kind}_events\")\n        end\n\n        private\n\n        def log_listeners\n          @log_listeners ||= Hash.new { |listeners, kind| listeners[kind] = [] }\n        end\n\n        def log_console_events\n          devtools.runtime.on(:console_api_called) do |params|\n            event = DevTools::ConsoleEvent.new(","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb#L42-L78","documentation":"HasLogEvents#on_log_event registers a listener for one of a fixed set of log event kinds (:console, :exception, :mutation). Passing any other kind raises Error::WebDriverError because there is no log_<kind>_events method to invoke. This is a Chromium/DevTools-backed feature.","triggerScenarios":"Calling driver.on_log_event(:network) { ... } or any kind not in KINDS = %i[console exception mutation].","commonSituations":"Typo in the kind symbol, expecting a kind that does not exist (e.g. :network, :error), passing a String instead of a Symbol, copying examples that assume more kinds than implemented.","solutions":["Use one of :console, :exception, or :mutation.","Pass a Symbol, not a String.","For other event types, use the lower-level BiDi or DevTools APIs directly instead of on_log_event."],"exampleFix":"// before\ndriver.on_log_event('console') { |e| ... }\ndriver.on_log_event(:network) { |e| ... }\n// after\ndriver.on_log_event(:console) { |e| ... }","handlingStrategy":"validation","validationCode":"VALID_LOG_KINDS = %i[console exception mutation].freeze\n\nraise ArgumentError, \"unknown log kind #{kind}\" unless VALID_LOG_KINDS.include?(kind.to_sym)\ndriver.on_log_event(kind.to_sym, &block)","typeGuard":"def valid_log_kind?(kind)\n  %i[console exception mutation].include?(kind.to_sym)\nend","tryCatchPattern":"begin\n  driver.on_log_event(kind, &block)\nrescue Selenium::WebDriver::Error::WebDriverError => e\n  raise unless e.message =~ /Don't know how to handle/\n  warn \"use :console, :exception, or :mutation\"\nend","preventionTips":["Restrict kinds to :console, :exception, :mutation.","Pass a Symbol, not a String.","Use lower-level BiDi/DevTools APIs for event types on_log_event does not cover."],"tags":["log-events","devtools","argument","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}