Run Web Automation Tests at Scale with Agentic AI

Generate tests with AI agents or automate test suites with Selenium, Playwright and other frameworks. Run tests in parallel on TestMu AI scalable cloud grid.

Selenium Tutorial

Selenium Wire Alternatives: How to Intercept Network Requests in Python [2026]

Selenium Wire is archived. Compare tested Python alternatives for network interception: Selenium CDP, Playwright routing, and mitmproxy, with copy-paste code.

Last Updated on:

Selenium Wire is an archived Python library that added request and response interception to Selenium. Its repository became read-only in January 2024, so teams now use Chrome DevTools Protocol commands, Playwright routing, or a mitmproxy proxy to capture, block, and mock network traffic in automated tests.

Selenium Wire used to be the easiest way to see and change network traffic in a Selenium test. You imported seleniumwire.webdriver, read driver.requests, and set an interceptor.

That convenience now carries a cost. The project is archived, so it will not follow new Selenium, Python, or browser releases.

This guide is for Python QA engineers who have Selenium Wire in an existing suite, or who are choosing an approach for a new one. It gives copy-paste code for four options, a feature mapping from Selenium Wire to each, and honest limits for each.

The Selenium CDP and Playwright snippets were tested with Selenium 4.40 and a current Chrome.

TL;DR

Selenium Wire is archived and no longer maintained, so new suites need a supported way to intercept traffic. Pick CDP for quick Chrome-only checks, Playwright for full routing and mocking, or mitmproxy when one proxy must serve many tools and browsers.

  • Status - The repository has been read-only since January 2024, so Selenium Wire will not track new Selenium, Python, or browser releases.
  • Native Selenium - CDP commands block URLs, add headers, and read response bodies in Chrome and Edge. Python request interception through BiDi is still maturing.
  • Playwright - The route API blocks, mocks, and modifies requests in Chromium, Firefox, and WebKit.
  • mitmproxy - A scriptable proxy that works with any browser and framework, including corporate upstream proxy setups.
  • Scale - Run the same tests on Automation Cloud, with network logs captured for every session.

Is Selenium Wire Still Maintained

No. Selenium Wire is no longer maintained: its GitHub repository was archived on January 3, 2024, and its last release came in October 2022, so it will not follow new Selenium or Chrome releases.

The README on the Selenium Wire GitHub repository confirms it. Here is what that means in practice:

  • No compatibility fixes. New Selenium, Python, and Chrome releases can break it, and nobody will patch it.
  • Dependency breakage. A guide from ScrapingBee explains that a fresh install can pull a newer blinker release that breaks the import. It suggests pinning an older blinker as a workaround.
  • No security updates. Selenium Wire runs a man-in-the-middle proxy between your browser and your app. An unmaintained proxy is a poor thing to leave in a CI image.
  • Forks are a gamble. Community forks exist. Check the commit history, open issues, and PyPI release dates before you depend on one.

If you only need to see traffic, a supported alternative is a small change. If you rely on request and response interceptors, plan a real migration.

The sections below show how, one option at a time.

What Are the Best Selenium Wire Alternatives

The best Selenium Wire alternatives are Selenium 4 CDP commands for Chrome checks, Playwright routing for mocking in any browser, and mitmproxy for shared proxy setups. BiDi is still maturing.

Each option covers a different slice of what Selenium Wire did. Use this table to shortlist before you read the code.

ApproachBrowsersBlock or modify requestsMock responsesRead response bodiesBest for
Selenium 4 + CDPChrome, EdgeYes (block URLs, extra headers)Not with execute_cdp_cmd aloneYes, via performance logQuick checks inside an existing Selenium suite
Selenium BiDiBrowsers with BiDi supportRequest handlers (maturing)Not in the Python API we testedLimitedWatching progress, not production yet
Playwright routingChromium, Firefox, WebKitYesYesYesNew suites and mock-heavy tests
mitmproxyAny browserYes (addon hooks)YesYesShared setups and enterprise networks

How to Block Requests and Read Responses in Selenium With CDP

Turn on the performance log, call execute_cdp_cmd with Network.enable, then Network.setBlockedURLs or Network.setExtraHTTPHeaders, and read bodies with Network.getResponseBody in Chrome or Edge.

If your suite already runs on Selenium and Chrome or Edge, the least disruptive move is to call the Chrome DevTools Protocol (CDP) through execute_cdp_cmd.

There is nothing extra to install beyond Selenium itself.

pip install selenium

The script below blocks images, adds a header to every request, and reads the body of one API response from the performance log.

import json
from selenium import webdriver

BASE_URL = "https://your-app.example.com"

options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
# Turn on the performance log so network events are recorded
options.set_capability("goog:loggingPrefs", {"performance": "ALL"})
driver = webdriver.Chrome(options=options)

try:
    driver.execute_cdp_cmd("Network.enable", {})

    # Block images and add a header to every request
    driver.execute_cdp_cmd("Network.setBlockedURLs", {"urls": ["*.png", "*.jpg"]})
    driver.execute_cdp_cmd(
        "Network.setExtraHTTPHeaders", {"headers": {"X-Test-Run": "ci-1042"}}
    )

    driver.get(BASE_URL)

    # Read the body of one API response from the recorded events
    for entry in driver.get_log("performance"):
        event = json.loads(entry["message"])["message"]
        if event["method"] != "Network.responseReceived":
            continue
        response = event["params"]["response"]
        if response["url"].endswith("/api/data.json"):
            body = driver.execute_cdp_cmd(
                "Network.getResponseBody", {"requestId": event["params"]["requestId"]}
            )
            print(response["status"], body["body"])
finally:
    driver.quit()

What to know before you adopt it:

  • CDP is a Chromium protocol, so this works in Chrome and Edge only.
  • execute_cdp_cmd sends commands but does not receive events, so you cannot fulfill or rewrite a request with it. For mocking, use Playwright or mitmproxy.
  • Network.getResponseBody can fail for redirects or responses the browser has already discarded, so read bodies soon after the request finishes.
  • The performance log records events for the whole session. Filter by URL to keep it readable.
Note

Note: Run your Selenium tests on cloud browsers across operating systems. Try TestMu AI Today!

Does Selenium BiDi Replace Selenium Wire

Not yet. Selenium 4 has a BiDi network module with request handlers, but the Python API is still maturing and continuing an intercepted request failed in our tests, so use CDP or Playwright today.

WebDriver BiDi is the standards-based successor to CDP. Selenium 4 ships a network module for it.

Enable BiDi with options.enable_bidi = True, then call driver.network.add_request_handler to continue, change, or fail a request.

See the Selenium Python network API reference and the BiDi network documentation.

We do not recommend it for production yet. Selenium's own documentation says some of the intercept helpers are not public until they stabilize.

In our test runs with Selenium 4.40 and a current Chrome, continuing an intercepted request failed with an "Invalid InterceptionId" error. The Python request object also has no way to supply a response body.

Re-test after each Selenium upgrade, and use CDP or Playwright for work that has to ship today.

How to Block and Mock Requests With Playwright

Use page.route or context.route with a URL pattern, then call route.abort to block a request or route.fulfill to return your own status, headers, and body. It works in Chromium, Firefox, and WebKit.

Playwright's route API is the closest match to what Selenium Wire interceptors did, and it works in Chromium, Firefox, and WebKit.

You can block, modify, or fulfill any request, and wait for specific responses without polling logs.

Install Playwright and its Chromium browser first:

pip install playwright
playwright install chromium

The script below blocks images, mocks an API response, adds a header to every request, and waits for a specific response.

import json
from playwright.sync_api import sync_playwright

BASE_URL = "https://your-app.example.com"

with sync_playwright() as p:
    browser = p.chromium.launch(headless=True)
    # Add a header to every request made in this context
    context = browser.new_context(extra_http_headers={"X-Test-Run": "ci-1042"})
    page = context.new_page()

    # Block images
    page.route("**/*.{png,jpg,jpeg}", lambda route: route.abort())

    # Mock an API response
    page.route(
        "**/api/data.json",
        lambda route: route.fulfill(
            status=200,
            content_type="application/json",
            body=json.dumps({"price": 999}),
        ),
    )

    # Log blocked requests and wait for a specific response
    page.on("requestfailed", lambda request: print("blocked:", request.url))
    with page.expect_response("**/api/data.json") as response_info:
        page.goto(BASE_URL)
    print(response_info.value.status, response_info.value.json())

    browser.close()

Notes for Selenium teams:

  • Playwright drives its own browser connection, so a Selenium WebDriver session cannot use page.route. Plan to move interception-heavy tests, not the whole suite.
  • Use context.route instead of page.route when you want the rule to apply to every page the test opens.
  • If your app uses service workers, requests they handle may bypass routing. Playwright can block service workers for the context when you need predictable interception.

For a full introduction to the framework, read our Playwright tutorial.

Test infrastructure that does not break, from TestMu AI

How to Use mitmproxy With Selenium

Write an addon with request and response hooks, run it with mitmdump on a local port, then start Chrome with the proxy-server argument so every browser request passes through your rules.

mitmproxy is an open-source, scriptable HTTPS proxy. You point the browser at it and write interception rules once in a Python addon.

That makes it the best fit when several teams, browsers, or tools need the same rules, or when all traffic must pass through a corporate proxy.

Step 1: Write the Addon

Save this as addon.py. It adds a header, blocks images, and mocks one API route, for your app host only.

# addon.py
from mitmproxy import http

APP_HOST = "your-app.example.com"


def request(flow: http.HTTPFlow) -> None:
    if flow.request.pretty_host != APP_HOST:
        return  # leave all other traffic untouched

    flow.request.headers["X-Test-Run"] = "ci-1042"

    if flow.request.path.endswith((".png", ".jpg")):
        flow.response = http.Response.make(204)  # block images
    elif flow.request.path.startswith("/api/data.json"):
        flow.response = http.Response.make(
            200, b'{"price": 999}', {"Content-Type": "application/json"}
        )  # mock the API


def response(flow: http.HTTPFlow) -> None:
    print(flow.response.status_code, flow.request.pretty_url)

Step 2: Run the Proxy

Start mitmdump with the addon. The second command chains it to a corporate proxy instead.

pip install mitmproxy
mitmdump -s addon.py --listen-port 8080

# Behind a corporate proxy, chain to it in upstream mode
mitmdump -s addon.py --listen-port 8080 --mode upstream:http://corp-proxy.example.com:3128

Step 3: Point Selenium at It

Send Chrome through the proxy with a browser argument. Everything else in your test stays the same.

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("--proxy-server=http://127.0.0.1:8080")
# Local experiments only. In shared environments, install the mitmproxy CA instead.
options.add_argument("--ignore-certificate-errors")

driver = webdriver.Chrome(options=options)
driver.get("https://your-app.example.com")
driver.quit()

Enterprise checklist:

  • Scope every rule by host, as the addon above does, so the proxy never rewrites unrelated traffic.
  • Trust the mitmproxy certificate authority on the test machines instead of using --ignore-certificate-errors outside local experiments.
  • Run mitmdump as a sidecar process or container in CI and give each parallel job its own port.
  • Use upstream mode when the network requires a corporate proxy. It replaces Selenium Wire's upstream proxy options.
Note

Note: Debug failing network calls with network logs captured for every session. Try TestMu AI Today!

How to Migrate From Selenium Wire

List the Selenium Wire features you use, map each to a replacement, then move tests one at a time: the performance log for reads, route or addon hooks for changes, and proxy settings for upstream.

Use this table to translate each Selenium Wire feature you rely on.

Selenium Wire featureSelenium CDPPlaywrightmitmproxy
Read traffic (driver.requests)Performance log eventspage.on("request") and page.on("response")response hook or saved flows
Add or change request headersNetwork.setExtraHTTPHeadersextra_http_headers or route.continue_request hook
Block requests (images, trackers)Network.setBlockedURLsroute.abortReturn an empty response from the request hook
Mock or rewrite responsesNot with execute_cdp_cmd aloneroute.fulfillResponse.make in the request hook
Upstream proxyBrowser proxy-server argumentproxy option on browser launchUpstream mode
Limit rules to certain URLs (scopes)URL patterns in the commandGlob patterns on routeHost and path checks in the addon

Running Intercepted Tests at Scale

Once interception works locally, the next question is how to run it across browsers and operating systems.

Automation Cloud from TestMu AI runs Selenium and Playwright tests on cloud browsers across many browser and OS combinations, with no grid to maintain.

To run Python scripts there, follow the support guide on running Python Selenium scripts on TestMu AI.

It can also cover part of what you used Selenium Wire for. Every session records network logs, console logs, video, and command logs automatically.

So you can often debug a failing API call without any interception code. Custom headers and proxy configuration are supported, and LT Tunnel lets cloud browsers reach staging or locally hosted apps.

When a test must block or mock requests, keep that logic in the test with Playwright routing or a proxy. Check which interception methods your target browsers support before you migrate.

Next-generation test execution with TestMu AI

Which Selenium Wire Alternative Should You Use

Use Selenium CDP for quick Chrome checks, Playwright routing for new suites and heavy mocking, and mitmproxy for shared or enterprise setups. Treat Selenium BiDi as experimental until it matures.

  • Stay on Selenium and Chrome: use CDP for blocking, headers, and reading response bodies.
  • Start a new suite or mock a lot of APIs: use Playwright routing.
  • Share rules across browsers, tools, or teams, or sit behind a corporate proxy: use mitmproxy.
  • Want a pure Selenium API: watch the BiDi network module and re-test it with each release.

Conclusion

Selenium Wire solved a real problem, but it is archived, and the supported alternatives are now good enough to replace it.

Use CDP for quick Chrome checks, Playwright when you need routing and mocking, and mitmproxy when interception must be shared.

Move the code you depend on, test it on your own app, and retire the pinned selenium-wire package.

For related reading, see our Selenium Grid setup tutorial.

Testing from the terminal? Kane CLI by TestMu AI lets SDETs and developers plan, write, run and debug tests from the command line.

To run your first test, start free, or
for a full walkthrough of the product.

Author

...

Upendra Prasad Mahto

Blogs: 9

  • Twitter
  • Linkedin

Upendra Prasad Mahto is a community contributor with 2+ years of experience across software engineering, test automation content, and technical writing. He specializes in creating content around test automation tools such as Selenium and Appium, along with topics in software quality and emerging AI technologies. Formerly a Technical Content Writer at TestMu AI, Upendra focuses on translating practical testing workflows and automation concepts for developers and QA professionals. He holds a B.Tech in Electronics and Communication Engineering and certifications in Generative AI and Product Analytics.

Reviewer

...

Himanshu Sheth

Reviewer

  • Linkedin

Himanshu Sheth is the Director of Marketing (Technical Content) at TestMu AI, with over 8 years of hands-on experience in Selenium, Cypress, and other test automation frameworks. He has authored more than 130 technical blogs for TestMu AI, covering software testing, automation strategy, and CI/CD. At TestMu AI, he leads the technical content efforts across blogs, YouTube, and social media, while closely collaborating with contributors to enhance content quality and product feedback loops. He has done his graduation with a B.E. in Computer Engineering from Mumbai University. Before TestMu AI, Himanshu led engineering teams in embedded software domains at companies like Samsung Research, Motorola, and NXP Semiconductors. He is a core member of DZone and has been a speaker at several unconferences focused on technical writing and software quality.

Add to Google preferred sources

Summarise with AI

Copied to Clipboard!
...

3000+ Browsers. One Platform.

See exactly how your site performs everywhere.

Try it free
...

Write Tests in Plain English with KaneAI

Create, debug, and evolve tests using natural language.

Try for free

Frequently asked questions

Did you find this page helpful?

More Related Blogs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests