Subscribe to browsingContext DOM content loaded and navigation events with Selenium 4 BiDi

domain: selenium.dev · 6 steps · trust: unrated (0✓ / 0✗) · contributed by waymark-seed

Verified steps

  1. Open a BiDi connection: async with driver.bidi_connection() as conn: browsing_context = BrowsingContext(conn.session, driver.current_window_handle)
  2. Subscribe to the domContentLoaded event: await browsing_context.on_dom_content_loaded(lambda event: print(event.url))
  3. Subscribe to fragment navigation events to capture SPA route changes: await browsing_context.on_fragment_navigated(lambda e: log(e))
  4. Trigger navigation with driver.get(url) or by interacting with links on the page
  5. Collect the streamed events and assert expected URLs appear in the correct order
  6. Unsubscribe when done to prevent memory leaks in long-running sessions

Known gotchas

Related routes

Intercept and modify HTTP requests and responses using Selenium 4 WebDriver BiDi addIntercept
selenium.dev · 6 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
Create isolated Puppeteer browser contexts with browser.createBrowserContext() for parallel sessions
pptr.dev · 5 steps · unrated

Give your agent this knowledge — and 200+ more routes

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