Playwright vs Selenium is the first decision in most browser automation projects, and for web scraping the trade-offs differ from the testing debates you usually see. This guide compares the two on architecture, languages and browsers, waiting, isolation, parallelism, network interception, speed and detection, then shows the same scraping task in both through an authenticated proxy. Every API, flag and version below was checked against Playwright 1.65 and Selenium 4.52, the current releases on PyPI as of 17 November 2026.
The short version
For new Python scraping projects, Playwright is usually the easier choice: it auto-waits, isolates sessions in cheap browser contexts, intercepts network traffic out of the box and takes proxy credentials as a plain option, per browser or per context. Choose Selenium when you need a W3C-standard protocol, the widest set of language bindings, real branded browsers through vendor drivers, or an existing Selenium Grid. Since Selenium 4 added WebDriver BiDi, it can also answer proxy authentication challenges without extensions or Selenium Wire.
Versions used. Playwright for Python 1.65.2 (bundling Chromium 159.0.8154.6, Firefox 159.0 and WebKit 27.2) and Selenium 4.52.0. Both packages now require Python 3.10 or newer. Proxy examples use ProxyEmpire’s gateway at v2.proxyempire.io:5000, with credentials read from environment variables.
Key takeaways
- Playwright drives each engine through its own protocol layer: CDP for Chromium, Juggler for its patched Firefox and a patched WebKit. Selenium speaks the W3C WebDriver standard to vendor drivers, plus WebDriver BiDi for events and network access.
- Playwright auto-waits before every action. Selenium waits only when you tell it to, with
WebDriverWait. - A Playwright browser context is an isolated, incognito-like session inside one browser process. Selenium usually isolates by starting a new browser session, and scales out with Selenium Grid.
- Playwright accepts
usernameandpasswordin itsproxyoption. Chrome ignores credentials in--proxy-server, so Selenium needs a BiDi auth handler (4.52 hasdriver.network.add_auth_handler) or an extension. - Selenium Wire’s repository was archived in January 2024. Don’t start new projects on it.
- Neither tool is built to be undetectable. Both expose automation signals, and the proxy only changes the IP.
Playwright vs Selenium at a Glance
The differences that matter for scraping| Topic | Playwright | Selenium |
|---|---|---|
| Maintainer, license | Microsoft, Apache-2.0 | Selenium project (Software Freedom Conservancy), Apache-2.0 |
| Protocol | Own client-server protocol; CDP, Juggler or WebKit’s inspector protocol underneath | W3C WebDriver (HTTP) plus WebDriver BiDi (WebSocket); CDP for Chromium-only extras |
| Official languages | JavaScript/TypeScript, Python, Java, .NET | Java, Python, C#, Ruby, JavaScript (Kotlin uses the Java bindings) |
| Browsers | Bundled Chromium, patched Firefox and WebKit; branded Chrome and Edge via channels | Branded Chrome, Edge, Firefox, Safari through their vendor drivers |
| Waiting | Automatic actionability checks, 30 s default timeout | Explicit waits (WebDriverWait); implicit wait defaults to 0 |
| Isolation | Browser contexts, many per browser | One session per browser; BiDi user contexts at a low level |
| Parallelism | Contexts, processes, your own job queue | Threads or processes locally, Selenium Grid across machines |
| Network interception | page.route() / context.route() on all engines | BiDi driver.network handlers in Selenium 4 |
| Authenticated proxy | proxy={"server", "username", "password"} | --proxy-server plus a BiDi auth handler, or an extension |
| Driver and browser setup | playwright install | Selenium Manager (automatic since 4.6) |
Architecture: How Each One Talks to the Browser
Most other differences follow from thisSelenium implements the W3C WebDriver standard. Your script sends each command (find element, click, get text) as an HTTP request to a driver process such as ChromeDriver or GeckoDriver. The browser vendor maintains that driver, and it translates the command into the browser’s internal automation interface. Classic WebDriver is request-response only: the browser can’t push events to you, so anything event-driven (console logs, network traffic, auth prompts) needs a second channel.
That channel is now WebDriver BiDi, a W3C protocol over WebSocket that adds events and network control. In Selenium’s Python bindings you switch it on with options.enable_bidi = True, then use modules such as driver.network, driver.script and driver.browser. Selenium also exposes raw CDP for Chromium browsers, but that is tied to specific Chrome versions. Our explainer on WebDriver BiDi vs CDP covers why the industry is moving to BiDi.
Playwright splits into a client library and a server. In Python, the package ships a Node.js driver and starts it as a subprocess (run-driver), then talks to it over a pipe with Playwright’s own JSON protocol. The server drives each engine through that engine’s native protocol: the Chrome DevTools Protocol for Chromium, a protocol called Juggler for its patched Firefox, and the inspector protocol of a patched WebKit build. One connection stays open for the whole run, and events flow both ways from the start.
SELENIUM
your script --HTTP per command--> chromedriver --CDP--> Chrome
<--WebSocket (BiDi)--> events, network, auth
PLAYWRIGHT (Python)
your script --pipe, one session--> Node driver --CDP--------> Chromium
--Juggler-----> patched Firefox
--inspector---> patched WebKit
In short, Selenium bets on a standard that browser vendors implement, so it works with unmodified branded browsers. Playwright owns the full stack, so features behave consistently across engines, at the cost of depending on its own Firefox and WebKit builds. The 1.65 source also contains experimental WebDriver BiDi backends, but they aren’t in the public docs yet.
Languages, Browsers and Setup
Both now install their own browsersPlaywright’s official languages are JavaScript/TypeScript, Python, Java and .NET, which “share the same underlying implementation”, so features land in all four at once. Selenium’s core bindings are Java, Python, C#, Ruby and JavaScript, all at 4.52.0; Kotlin projects use the Java bindings. If your team writes Ruby, Selenium is the only one of the two with an official client.
For browsers, Playwright 1.65.2 pins Chromium 159.0.8154.6, Firefox 159.0 and WebKit 27.2. Its browser docs say it doesn’t work with branded Firefox or Safari because it relies on patches, while branded Chrome and Edge work through channels such as chrome and msedge. By default, headless Chromium runs a separate headless shell build; channel="chromium" opts into Chrome’s new headless mode. Selenium drives whatever branded browser the vendor driver supports, including Safari through Apple’s safaridriver.
# Playwright: the library, then its browser builds
pip install playwright==1.65.2
playwright install chromium # or: playwright install --with-deps chromium (Linux CI)
# Selenium: the library only. Selenium Manager fetches drivers
# (and Chrome for Testing, if no Chrome is installed) on first run.
pip install selenium==4.52.0
Selenium Manager has shipped with every release since 4.6. It discovers, downloads and caches the right driver, and since 4.11 it can also download browsers (Chrome for Testing for Chrome), caching them in ~/.cache/selenium. The docs still describe it as beta. The old “ChromeDriver version mismatch” pain is largely gone in both tools.
Auto-Waiting vs Explicit Waits
The biggest day-to-day differencePlaywright auto-waits: before an action, it checks that the target is visible, stable, receives events and is enabled (plus editable for fill()), retrying until the checks pass or the 30-second default timeout expires. Locators are lazy and re-resolved on each use, so a re-rendered element doesn’t leave you holding a stale reference.
Selenium does what you say, immediately. find_element fails at once if the element isn’t in the DOM yet, because the implicit wait defaults to 0. The Selenium docs recommend explicit waits with WebDriverWait and expected conditions, which poll every 0.5 seconds by default, and warn not to mix implicit and explicit waits.
# Playwright: waiting is built into the action
page.locator("li.next a").click()
# Selenium: wait explicitly, then act
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 15).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, "li.next a"))
).click()
Selenium’s way is more code but fully explicit. Playwright’s way is shorter and harder to get wrong.
Isolation and Parallelism
Browser contexts vs one browser per sessionA Playwright browser context is an incognito-like profile inside a running browser. The docs call contexts “fast and cheap to create and completely isolated, even when running in a single browser”: each has its own cookies, local storage and session storage. For scraping, that means one Chromium process can host many independent sessions, each with its own cookies and, as shown below, its own proxy.
Classic WebDriver has no equivalent. The usual Selenium pattern is one browser per session, which gives strong isolation but costs a full browser process each time. WebDriver BiDi adds user contexts (browser.createUserContext, exposed in Python as driver.browser.create_user_context()), but this is a low-level API and much less used than Playwright contexts.
For parallelism, Playwright leaves the orchestration to you: several contexts per browser, several browsers per process, several worker processes per machine. Selenium has a mature answer for spreading work across machines in Selenium Grid, which runs as a single standalone process, as hub and nodes, or fully distributed. Playwright can attach Chromium sessions to a Grid via SELENIUM_REMOTE_URL, but its docs label this experimental and limited to Chrome and Edge. For what a large Playwright fleet looks like in practice, see our article on designing a browser cluster for 10,000 concurrent Chromium sessions.
Network Interception
Blocking, modifying and mocking requestsScrapers intercept requests to block images and fonts (saving proxy bandwidth), to read JSON API responses directly, or to add headers. Playwright has had this from the start: page.route() or context.route() with route.abort(), route.continue_() or route.fulfill(), on all three engines (network docs).
Selenium 4 now covers the same ground through BiDi. In 4.52, driver.network.add_request_handler() takes glob patterns and a handler that can observe, modify or fail() a request. Its glob syntax supports *, ** and ? but not braces, so list each pattern.
# Playwright: abort matching requests for the whole context
context.route("**/*.{png,jpg,jpeg,webp}", lambda route: route.abort())
# Selenium 4.52: needs options.enable_bidi = True before the driver starts
driver.network.add_request_handler(
["**/*.png", "**/*.jpg", "**/*.jpeg", "**/*.webp"],
lambda request: request.fail(),
)
In both tools, every intercepted request pauses until your handler answers, so keep patterns narrow and handlers fast.
Which One Is Faster, and Why
Reasons, not invented benchmarksSpeed results depend on the site, the network and how the script is written, so we don’t quote a number. These are the structural reasons Playwright often comes out ahead, and where the gap closes:
- Fewer round trips. Classic WebDriver sends one HTTP request per command to the driver, which then calls the browser. Playwright keeps one persistent connection open, and its locators combine waiting and acting in one call.
- Waiting happens inside the stack.
WebDriverWaitpolls from your script every 0.5 s by default, so each wait can overshoot the moment the element appears. Playwright’s actionability checks run on the server side. - Cheap sessions. A new context takes far less than a new browser launch, which matters when every job needs a clean cookie jar.
- An extra hop in Python. Playwright for Python routes everything through a Node.js driver process, which adds a little overhead to each call.
- The network dominates. Through residential or mobile proxies, page loads take far longer than automation commands. At that point, blocking heavy resources and reusing sessions matter more than which library sends the clicks.
If speed decides the choice, benchmark your own pages through your own proxy setup, with the same concurrency, before committing.
Detection and Fingerprints
Neither is built to be invisibleSites that use bot management look at much more than the IP address. They check browser-level signals such as navigator.webdriver (the WebDriver spec defines it as true when a browser is under WebDriver control), differences in headless mode, side effects of the automation protocol, and the consistency of the whole fingerprint: User-Agent, fonts, WebGL, time zone, language. Our browser fingerprinting explainer goes through these in detail.
Stock Playwright and stock Selenium are both testing tools and both are detectable. Community projects patch each of them: on the Selenium side, undetected-chromedriver and SeleniumBase (whose PyPI description says its “CDP Mode adds stealth”); on the Playwright side, forks such as Patchright and Firefox-based Camoufox. We compare the Selenium-family options in undetected-chromedriver vs nodriver vs SeleniumBase. None of them guarantees access, and their results change as detection vendors update.
What a proxy changes is narrower: the exit IP, its reputation and its location. A residential or mobile IP avoids the instant flags that datacenter ranges attract, and a sticky session keeps the IP steady while cookies accumulate. Keep the rest of the browser consistent with that IP (for example, a time zone and locale that match the exit country).
Proxies in Playwright vs Selenium
Where the two differ most for scrapersPlaywright: credentials are a normal option
Playwright’s proxy setting is a dictionary with server, optional username and password, and an optional bypass list. You can pass it to launch() for the whole browser, or to new_context() so each context gets its own proxy. Playwright answers the proxy’s 407 challenge itself, so no extension or helper proxy is needed.
On Chromium, per-context proxies need no special launch setting in current versions. Playwright 1.65 creates each context with its own proxy through CDP’s Target.createBrowserContext.
One limit applies to every Chromium-based tool, Playwright included: Chromium doesn’t support username/password authentication on SOCKS5 proxies, and Playwright rejects that combination with “Browser does not support socks5 proxy authentication”. Use the HTTP endpoint (HTTPS sites still work through CONNECT).
Selenium: Chrome won’t take credentials in the flag
With Selenium and Chrome, --proxy-server=http://host:port sets the proxy, but Chrome ignores a user:pass@ part and shows a sign-in prompt instead. Neither the classic WebDriver proxy capability nor BiDi’s session proxy configuration has fields for credentials. Your options in 2026:
options.enable_bidi = True, then call driver.network.add_auth_handler(username, password) before the first page load. The BiDi spec defines auth challenges for both 401 and 407 (Proxy-Authenticate) responses.--load-extension from branded Chrome builds; it still works in Chromium and Chrome for Testing.Selenium 4.52 also has a callback form, driver.network.add_authentication_handler(), that can scope credentials by URL pattern or cancel a challenge. Don’t register both forms at once: the docstring warns that both would answer the same challenge and the second response fails. Our Selenium proxy guide covers every option in depth, including Firefox; for the Node.js side, see our Puppeteer proxy guide.
Rotation and sticky sessions with ProxyEmpire
ProxyEmpire uses one gateway, v2.proxyempire.io:5000, with username and password authentication. Targeting and rotation live in the username, which you copy from the Connection Builder in the dashboard’s Proxy Manager. Choose Same IP for a sticky session (one IP until you rotate), Every request for rotation, or Custom TTL to rotate on a timer of up to 2 hours. A sticky username carries an 8-digit session ID, and a new session ID means a new IP.
For browser scraping, sticky usually fits best: a site that sets cookies on page one expects page two from the same IP. With Playwright you can map one sticky username to each context; with Selenium, start a new driver per identity. Our guide to sticky vs rotating proxies explains when each mode makes sense.
Side by Side: the Same Scraper in Both
Exit IP check, then titles and prices, through one proxyBoth scripts do the same job: open a page that echoes the exit IP, then load books.toscrape.com (a sandbox built for scraping practice) and print the first five titles and prices. Set the credentials first:
# Paste the username from Proxy Manager > Connection Builder
export PROXYEMPIRE_USERNAME='USERNAME'
export PROXYEMPIRE_PASSWORD='PASSWORD'
import os
from playwright.sync_api import sync_playwright
PROXY = {
"server": "http://v2.proxyempire.io:5000",
"username": os.environ["PROXYEMPIRE_USERNAME"],
"password": os.environ["PROXYEMPIRE_PASSWORD"],
}
with sync_playwright() as p:
browser = p.chromium.launch(headless=True, proxy=PROXY)
page = browser.new_page()
page.goto("https://api.ipify.org/")
print("Exit IP:", page.inner_text("body"))
page.goto("https://books.toscrape.com/")
cards = page.locator("article.product_pod")
cards.first.wait_for() # all() below doesn't wait, so wait once here
for card in cards.all()[:5]:
title = card.locator("h3 a").get_attribute("title")
price = card.locator("p.price_color").inner_text()
print(f"{price} {title}")
browser.close()
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
options.add_argument("--proxy-server=http://v2.proxyempire.io:5000") # no credentials here
options.enable_bidi = True # required for driver.network
driver = webdriver.Chrome(options=options) # Selenium Manager resolves ChromeDriver
try:
# Answer the proxy's 407 challenge over WebDriver BiDi
handler_id = driver.network.add_auth_handler(
os.environ["PROXYEMPIRE_USERNAME"],
os.environ["PROXYEMPIRE_PASSWORD"],
)
driver.get("https://api.ipify.org/")
print("Exit IP:", driver.find_element(By.TAG_NAME, "body").text)
driver.get("https://books.toscrape.com/")
cards = WebDriverWait(driver, 15).until(
EC.presence_of_all_elements_located((By.CSS_SELECTOR, "article.product_pod"))
)
for card in cards[:5]:
title = card.find_element(By.CSS_SELECTOR, "h3 a").get_attribute("title")
price = card.find_element(By.CSS_SELECTOR, "p.price_color").text
print(f"{price} {title}")
driver.network.remove_auth_handler(handler_id)
finally:
driver.quit()
The structure is almost identical. The differences are the ones described above: Playwright takes credentials in the launch options and waits for you; Selenium needs BiDi turned on, an auth handler registered before the first get(), and an explicit wait. If the Selenium script stops at a sign-in prompt or times out, check that enable_bidi is set before the driver is created.
Playwright can go one step further and give each context its own exit IP inside a single browser. Copy two sticky usernames with different session IDs from the Connection Builder:
import os
from playwright.sync_api import sync_playwright
SERVER = "http://v2.proxyempire.io:5000"
PASSWORD = os.environ["PROXYEMPIRE_PASSWORD"]
USERNAMES = [
os.environ["PROXYEMPIRE_USERNAME_1"], # sticky session A
os.environ["PROXYEMPIRE_USERNAME_2"], # sticky session B
]
with sync_playwright() as p:
browser = p.chromium.launch(headless=True) # no browser-wide proxy needed
for username in USERNAMES:
context = browser.new_context(
proxy={"server": SERVER, "username": username, "password": PASSWORD},
locale="en-US",
timezone_id="America/New_York", # match the exit country you target
)
page = context.new_page()
page.goto("https://api.ipify.org/")
print(page.inner_text("body"))
context.close()
browser.close()
With Selenium, the equivalent is one driver per sticky username, each with its own auth handler: heavier per session, but simple. For more Python patterns (requests, httpx, Scrapy), see Python web scraping with residential proxies.
Playwright vs Selenium: Which to Choose
A decision table, not a winner| Choose Playwright if… | Choose Selenium if… |
|---|---|
| You are starting a new Python, Node.js, Java or .NET scraper | Your team writes Ruby, or already has a large Selenium codebase |
| Pages are JavaScript-heavy and timing bugs are your main pain | You want explicit control over every wait |
| You need many isolated sessions per machine, each with its own proxy | You need to spread sessions across machines with Selenium Grid |
| You want network routing, tracing and codegen built in | You want to build on W3C standards (WebDriver, WebDriver BiDi) |
| Proxy credentials should be a plain config value | You must automate branded Firefox or Safari, which Playwright can’t drive |
| Bundled, version-pinned browsers suit your deployment | Your stack depends on the Selenium-based stealth tools (undetected-chromedriver, SeleniumBase) |
If you have no existing code and no Grid, Playwright is the shorter path to a working, proxied scraper. If you have either, Selenium 4 with BiDi has closed most of the gaps that used to justify a rewrite.
On the tooling side, playwright codegen [url] records your clicks into a script and playwright show-trace opens recorded traces for debugging.
Responsible Use
Same rules whichever tool you pick- Prefer an official API or data feed when the site offers one.
- Respect the site’s terms of service and robots.txt, and collect only public data you are allowed to use. Don’t scrape behind logins you aren’t authorized to use.
- Rate-limit yourself. Cap concurrency per domain and back off on 429 and 503 responses, honoring
Retry-After. - Treat CAPTCHAs and blocks as a stop signal, not a puzzle. Ask the site owner for access instead.
- Handle personal data lawfully under the rules that apply to you, such as GDPR or CCPA.
Frequently Asked Questions
Playwright vs Selenium in shortIs Playwright better than Selenium for web scraping?
For most new projects, yes. It auto-waits, isolates sessions cheaply in browser contexts, intercepts requests natively and accepts proxy credentials directly. Selenium remains the better fit for W3C-standard tooling, branded Firefox and Safari, Ruby, and existing Selenium Grid setups.
Is Playwright faster than Selenium?
Often, for structural reasons: a persistent connection instead of one HTTP request per command, built-in waiting and cheap contexts. Through proxies, network time usually dominates, so benchmark your own pages before deciding on speed alone.
How do I use a proxy with username and password in Selenium?
Chrome ignores credentials in --proxy-server. In Selenium 4.52, set options.enable_bidi = True, pass the proxy host and port in --proxy-server, and call driver.network.add_auth_handler(username, password) before loading a page. Use an HTTP proxy endpoint, not SOCKS5.
Can Playwright use a different proxy for each browser context?
Yes. Pass proxy={"server": ..., "username": ..., "password": ...} to browser.new_context(). In Playwright 1.65, Chromium needs no browser-wide placeholder proxy for this.
Is Selenium Wire still maintained?
No. Its GitHub repository was archived on 3 January 2024, and the last PyPI release, 5.1.0, dates from October 2022. Selenium 4’s BiDi driver.network module covers its main uses: request interception and proxy authentication.
Do Playwright and Selenium both support WebDriver BiDi?
Selenium supports BiDi officially, through enable_bidi and modules such as driver.network. Playwright’s documented engines still run on CDP, Juggler and patched WebKit; the 1.65 source contains experimental BiDi backends, but they aren’t in the public docs.
Give Playwright or Selenium a clean, targeted exit IP
ProxyEmpire’s single authenticated gateway works with both tools. Choose sticky sessions or rotation in the Connection Builder, target by country, city or ISP on rotating residential and by carrier on rotating mobile, and run as many concurrent sessions as your scraper needs.



