Skip to content

Using Selenium Wire in Python: Capture Traffic, Proxies and Fixes

Selenium Wire sits between a Selenium-driven browser and the sites it visits, exposing the requests and responses that ordinary page automation hides. This guide explains how to inspect and alter that traffic, route it through authenticated proxies, diagnose common setup failures, and choose a maintained path when the original package is no longer a good fit.

What Selenium Wire adds to Selenium

Selenium controls visible page behaviour, while Selenium Wire exposes the network layer underneath it. A local proxy receives each outgoing request and each returning response, so code can read URLs, methods, headers, status codes and bodies, or change traffic before it continues. The same mechanism works in visible and headless sessions and captures both XMLHttpRequest and fetch calls. The project name is Selenium Wire, the original package name is selenium-wire, and the Python import is seleniumwire. Use a checkpoint mindset: decide which traffic matters, inspect it at that point, and avoid storing every asset by default.

Maintenance status and the safer install path

The original project was archived on 3 January 2024 after its final October 2022 release, so new bug fixes and compatibility work should not be expected from it. Existing pinned scripts may continue to run, but a fresh environment can pull dependencies that were never tested with that release. The maintained selenium-wire-lw fork is the practical default for new work because it retains the seleniumwire import while supporting newer Python and Selenium versions. Treat the archived package as suitable only for a quick experiment or a working legacy setup.

Install, verify, and handle the blinker failure

Start in a fresh virtual environment, install Selenium together with selenium-wire-lw, and confirm that Chrome is available; Selenium Manager normally supplies the matching driver. A minimal check loads a public demo page and prints a captured URL with a 200 status. If an older tutorial leads to the archived package and startup fails with ModuleNotFoundError for blinker._saferef, the cause is an unpinned dependency: newer Blinker releases removed the private module the old package expects. Prefer replacing the archived package with the fork. Pinning an older Blinker can clear that one error, but it leaves the wider compatibility risk in place.

Reading requests, responses and JSON payloads

Captured entries are available through driver.requests. Each entry exposes request details, and its response property provides status, headers and body when a response exists. Always test for a missing response before reading it, because a request may still be running, may have failed, or may never have received a reply. For a JSON call, wait for the matching request, decode the raw response bytes according to their content encoding, convert them to text, and parse the JSON. A useful field map is: URL and method identify the call; request headers show what was sent; response status and headers describe the reply; response body carries the payload. Clearing old entries between actions prevents unrelated traffic from contaminating later checks.

Changing traffic and reducing noise

An interceptor runs before a request leaves the browser, so assign it before navigation. It can add or replace headers, adjust query parameters, or suppress selected calls. When replacing a header such as User-Agent, remove the previous value first because duplicate header names are permitted and can otherwise produce two versions. A custom header is a straightforward test; changing the user agent may help with testing but should not be treated as a dependable remedy for automated-browser blocking. For filtering, the fork uses include and exclude URL patterns, while the original package used scopes. Set patterns before the relevant request occurs, or capture everything and filter by content type afterwards.

Authenticated proxies and verification

With the maintained fork, proxy settings are supplied through SeleniumWireOptions and ProxyConfig when the browser is created. Credentials embedded in the proxy URL are attached by the proxy layer, avoiding a browser login prompt or a separate credential extension. Use one upstream endpoint for both HTTP and HTTPS; different endpoints for the two schemes are not supported by the fork. Exclude localhost and loopback addresses when local services should bypass the proxy. To verify routing, compare the public IP reported by a test page with and without the proxy. Any publisher-specific proxy-mode endpoint, credential mapping or API parameters require owner confirmation: {{OWNER_PROXY_MODE_ENDPOINT}}.

Why HTTPS warnings appear and how to resolve them

The security warning is expected when HTTPS inspection is enabled: the local proxy creates replacement certificates signed by its own authority, and the browser does not trust that authority initially. Scripts may still run, especially headless, but navigation can stop if a warning page appears. Use a predictable storage directory, run the browser once, then import the generated CA certificate into the appropriate browser Authorities store or operating-system trusted roots and restart the browser. Never trust a shared certificate or one generated elsewhere, because possession of the matching private key would allow traffic interception.

Choosing a maintained alternative

Choose by the actual bottleneck. For the smallest migration, selenium-wire-lw preserves familiar imports and request objects. SeleniumBase CDP Mode uses the Chrome DevTools Protocol without a man-in-the-middle proxy and is appropriate when staying close to Selenium matters. Playwright offers native network monitoring, blocking, modification and mocking, but its browser and element APIs require migration. mitmproxy suits proxy-level inspection across clients when browser automation is managed separately. If the difficulty is obtaining a response because of IP blocks, rate limits or anti-bot challenges, interception alone will not solve it; a managed scraping service may be more suitable, subject to {{OWNER_SCRAPING_SERVICE}}.

Common Selenium Wire symptoms and fixes
SymptomLikely causeFix
ModuleNotFoundError: No module named 'blinker._saferef'A newer incompatible Blinker version was installedInstall selenium-wire-lw, or pin Blinker only if the original package must be retained
Your connection is not secureThe browser does not trust the local inspection certificate authorityImport the CA certificate generated by your own installation
driver.requests is emptyThe request is unfinished or excluded by URL filtersUse wait_for_request, check the pattern, and widen include_urls or scopes
Import errors with Selenium 4.xThe archived package depends on changed Selenium behaviourReplace it with selenium-wire-lw
Installation breaks on Python 3.12+Old dependencies or removed Python APIs no longer matchUse selenium-wire-lw in a fresh virtual environment

Diagnostic summary for the archived package and the maintained fork; configuration names differ between them.

Frequently asked questions

Is Selenium Wire deprecated?

The original project is no longer maintained. Its repository was archived in January 2024 and its final release was version 5.1.0 in October 2022. For current work, use the maintained selenium-wire-lw fork or a native alternative.

What is the difference between Selenium and Selenium Wire?

Selenium drives the browser: opening pages, clicking, filling forms and running JavaScript. Selenium Wire adds visibility into the HTTP and HTTPS traffic behind those actions, including requests, responses, headers, bodies and proxy routing.

What is the best alternative to Selenium Wire?

Match the choice to your main constraint. If you want the least disruptive move, the selenium-wire-lw fork keeps the workflow familiar. For native interception in a new automation stack, Playwright is a strong fit. SeleniumBase CDP Mode keeps you nearer Selenium-style tooling, while mitmproxy is better when you need control at the proxy layer across different clients. When repeated blocking, rather than traffic visibility, is the obstacle, a managed scraping service may address the underlying problem.

Why won't Selenium Wire install?

Fresh installs often fail because the archived package depends on older library behaviour. A frequent symptom is the blinker._saferef import error caused by dependency drift. Installing selenium-wire-lw in a fresh virtual environment is usually the fastest remedy.

How do I fix 'Your connection is not secure' in Selenium Wire?

The warning occurs because HTTPS traffic is decrypted using a certificate authority generated locally for inspection. Import that generated CA certificate into the browser Authorities store or the operating system trusted roots, then restart the browser. Trust only a CA created by your own installation.

How do I use an authenticated proxy with Selenium Wire?

With selenium-wire-lw, create a ProxyConfig containing a proxy URL with credentials, pass it through SeleniumWireOptions when creating the driver, and use the same upstream endpoint for both HTTP and HTTPS traffic.

Captured requests: 1

GET https://dummyjson.com/products?limit=3
Status: 200
Content type: application/json; charset=utf-8
Products:
- Essence Mascara Lash Princess ($9.99)
- Eyeshadow Palette with Mirror ($19.99)
- Powder Canister ($14.99)

User API captured: False
{"ip":"203.0.113.10"}