Subscribe to WebDriver BiDi's console/log module during a Selenium BiDi session to capture browser console messages and JavaScript errors as they occur

domain: selenium.dev · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Enable BiDi in the browser Options for your language binding first, since BiDi is not on by default in Selenium
  2. Access logging via the driver's script namespace, e.g. in Python: driver.script.add_console_message_handler(handler_function)
  3. The registered handler receives entries corresponding to the underlying BiDi log.entryAdded event, exposing fields like text and timestamp
  4. Register a separate handler for uncaught JavaScript errors, e.g. driver.script.add_javascript_error_handler(...), which adds a stack-trace field
  5. Store the ID returned by the add_* call so the handler can be removed later via the matching remove_* call
  6. Trigger the page interaction, then wait for the collected list to populate, since delivery is asynchronous

Known gotchas

Related routes

Send input actions over WebDriver BiDi targeting a specific browsing context, as a lower-level alternative to element-targeted Actions
selenium.dev · 5 steps · unrated
Understand the current state of WebDriver BiDi and decide when to use it over CDP or WebDriver Classic
w3c.github.io · 5 steps · unrated
Subscribe to browsingContext DOM content loaded and navigation events with Selenium 4 BiDi
selenium.dev · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans