{"record":{"id":"b2a969166967623a","repo":"SeleniumHQ/selenium","slug":"message-error-message-message-messa","errorCode":null,"errorMessage":"#{message['error']}: #{message['message']}\n#{message['stacktrace']}","messagePattern":"#(.+?): #(.+?)\n#(.+?)","errorType":"exception","errorClass":"Error::WebDriverError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/bidi.rb","lineNumber":64,"sourceCode":"        @ws.callbacks\n      end\n\n      def add_callback(event, &block)\n        @ws.add_callback(event, &block)\n      end\n\n      def remove_callback(event, id)\n        @ws.remove_callback(event, id)\n      end\n\n      def session\n        @session ||= Session.new(self)\n      end\n\n      def send_cmd(method, **params)\n        data = {method: method, params: params.compact}\n        message = @ws.send_cmd(**data)\n        raise Error::WebDriverError, error_message(message) if message['error']\n\n        message['result']\n      end\n\n      def error_message(message)\n        \"#{message['error']}: #{message['message']}\\n#{message['stacktrace']}\"\n      end\n    end # BiDi\n  end # WebDriver\nend # Selenium\n","sourceCodeStart":46,"sourceCodeEnd":75,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/bidi.rb#L46-L75","documentation":"BiDi.send_cmd issues a WebDriver BiDi (bidirectional) websocket command and reads the response. If the browser's response hash contains an 'error' key, Selenium raises Error::WebDriverError with the error name, message, and JS stacktrace from the browser. It surfaces protocol-level failures of any BiDi command (script, network, browsingContext, etc.).","triggerScenarios":"Any BiDi call — bidi.session, script calls, network intercept install, browsingContext commands — whose parameters the browser rejects, or a method unsupported by the running browser, returns a response with message['error'] set, tripping the raise in send_cmd.","commonSituations":"Calling a BiDi method not yet implemented in the installed browser version, malformed command params, browser crashed/restarted mid-session, Selenium client newer/older than browser BiDi support, enabling webSocketCapability: true against a grid that does not proxy BiDi.","solutions":["Read the embedded stacktrace and error token from the message to identify the exact BiDi method/param the browser rejected.","Verify the browser version supports that BiDi command (check the W3C BiDi spec coverage for your browser).","Align Selenium client and browser/driver versions.","Validate command kwargs against the BiDi schema before calling send_cmd.","If transient (browser restart), recreate the BiDi session and retry once."],"exampleFix":"// before\nbidi.send_cmd(:someCommand, params: x)\n// after\nbegin\n  bidi.send_cmd(:someCommand, params: x)\nrescue Selenium::WebDriver::Error::WebDriverError => e\n  warn \"BiDi command failed: #{e.message}\"\nend","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"begin\n  result = bidi.send_cmd(method_name, **params)\nrescue Selenium::WebDriver::Error::WebDriverError => e\n  # e.message contains 'error: ...\\n<stacktrace>'\n  raise unless e.message =~ /no such|invalid|unknown method/i\n  # recover: log and degrade\nend","preventionTips":["Pin Selenium client, browser, and driver to mutually compatible versions.","Log the full BiDi response (including stacktrace) when debugging.","Check browser BiDi coverage for a command before adopting it.","Recreate the BiDi session after a browser restart rather than reusing a stale one."],"tags":["bidi","websocket","browser","protocol","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}