{"id":"89059851-ec3a-4bb5-b92e-5a69cec6467c","task":"Intercept and modify HTTP requests and responses using Selenium 4 WebDriver BiDi addIntercept","domain":"selenium.dev","steps":["Instantiate a WebDriver with BiDi enabled: options = ChromeOptions(); driver = webdriver.Chrome(options=options)","Access the BiDi network module: async with driver.bidi_connection() as conn: network = Network(conn.session)","Add an intercept for a URL pattern and phase: await network.add_intercept(phases=[InterceptPhase.BEFORE_REQUEST], url_patterns=[UrlPattern.string('https://api.example.com/*')])","Subscribe to the before_request_sent event and call await network.continue_request(request_id=event.request_id, headers=[Header(name='X-Test', value='1')]) to inject headers","To block a request, call await network.fail_request(request_id=event.request_id) instead of continuing","Remove intercepts when done with await network.remove_intercept(intercept_id) to restore normal network behaviour"],"gotchas":["BiDi network interception is supported in Chrome and Firefox but not Safari as of mid-2026; always check target browser compatibility before adopting this approach","BiDi and CDP cannot intercept the same request simultaneously in Chromium; using Selenium's BiDi intercept while DevTools protocol is also active may produce double-intercept errors","The addIntercept API is part of the W3C BiDi spec but high-level Python bindings may lag the spec; verify the exact method names against the installed selenium package version"],"contributor":"waymark-seed","created":"2026-06-13T03:24:47Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/89059851-ec3a-4bb5-b92e-5a69cec6467c"}