{"record":{"id":"9191c637d57d618c","repo":"SeleniumHQ/selenium","slug":"bidi-was-enabled-but-the-remote-end-did-not-retur","errorCode":null,"errorMessage":"BiDi was enabled, but the remote end did not return a valid webSocketUrl: #{url.inspect}.","messagePattern":"BiDi was enabled, but the remote end did not return a valid webSocketUrl: #(.+?)\\.","errorType":"exception","errorClass":"Error::WebDriverError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/remote/bidi_bridge.rb","lineNumber":86,"sourceCode":"        def quit\n          bidi&.close\n        rescue *QUIT_ERRORS\n          nil\n        ensure\n          super\n        end\n\n        def close\n          execute(:close_window).tap { |handles| bidi.close if handles.empty? }\n        end\n\n        private\n\n        def validated_socket_url\n          url = @capabilities[:web_socket_url]\n          return url if url.is_a?(String) && url.start_with?('ws://', 'wss://')\n\n          raise Error::WebDriverError,\n                \"BiDi was enabled, but the remote end did not return a valid webSocketUrl: #{url.inspect}.\"\n        end\n\n        def browsing_context\n          @browsing_context ||= BiDi::Protocol::BrowsingContext.new(connection)\n        end\n\n        def readiness_state\n          READINESS_STATE.fetch(capabilities[:page_load_strategy] || 'normal')\n        end\n      end # BiDiBridge\n    end # Remote\n  end # WebDriver\nend # Selenium\n","sourceCodeStart":68,"sourceCodeEnd":101,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/remote/bidi_bridge.rb#L68-L101","documentation":"Raised by BiDiBridge#validated_socket_url (Error::WebDriverError) during BiDi session creation when the webSocketUrl capability returned by the remote end is missing or not a ws:///wss:// URL. Selenium requested BiDi (the capabilities included the webSocketUrl flag) but the server did not hand back a usable WebSocket endpoint to connect to.","triggerScenarios":"Enabling webSocketUrl: true in capabilities against a remote end (older driver or Grid) that does not support the WebDriver BiDi protocol; the server accepted the session but omitted/returned a malformed webSocketUrl.","commonSituations":"Using an outdated browser/driver or Selenium Grid version that predates BiDi support; pointing at a third-party grid that strips the webSocketUrl capability; enabling BiDi without ensuring the remote advertises it.","solutions":["Upgrade the browser, driver, and Selenium Grid/Server to versions that support WebDriver BiDi.","Confirm the remote end actually supports BiDi (check returned capabilities for webSocketUrl) before enabling it.","If BiDi is optional, fall back to disabling webSocketUrl: true when the remote end does not support it."],"exampleFix":"// before\noptions = Selenium::WebDriver::Firefox::Options.new(web_socket_url: true)\ndriver = Selenium::WebDriver.for(:remote, url: grid_url, capabilities: options)\n# remote returns no webSocketUrl -> error\n\n// after\n# ensure grid/browser/driver support BiDi, then\noptions = Selenium::WebDriver::Firefox::Options.new(web_socket_url: true)\ndriver = Selenium::WebDriver.for(:remote, url: grid_url, capabilities: options)","handlingStrategy":"validation","validationCode":"# Probe support before requiring BiDi\nsession_caps = driver.capabilities\nunless session_caps[:web_socket_url].to_s.start_with?('ws')\n  raise 'Remote end does not support WebDriver BiDi; disable web_socket_url or upgrade'\nend","typeGuard":null,"tryCatchPattern":"begin\n  driver = Selenium::WebDriver.for(:remote, url: url, capabilities: bidi_options)\nrescue Selenium::WebDriver::Error::WebDriverError => e\n  raise unless e.message.include?('webSocketUrl')\n  # fall back to classic mode without BiDi\n  driver = Selenium::WebDriver.for(:remote, url: url, capabilities: classic_options)\nend","preventionTips":["Ensure browser, driver, and Grid/Server versions support WebDriver BiDi before enabling web_socket_url.","Treat BiDi as optional: fall back to classic mode when the remote lacks webSocketUrl.","Verify the returned capabilities include a ws/wss webSocketUrl after session creation."],"tags":["bidi","capabilities","websocket","remote","session"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}