Playwright vs Selenium: Which Should Python Developers Use?
Playwright wins for new Python projects in 2026. It runs 44% faster than Selenium on React SPAs, eliminates flaky waits with built-in auto-waiting, and ships bo

Playwright wins for new Python projects in 2026. It runs 44% faster than Selenium on React SPAs, eliminates flaky waits with built-in auto-waiting, and ships bo

Playwright wins for new Python projects in 2026. It runs 44% faster than Selenium on React SPAs, eliminates flaky waits with built-in auto-waiting, and ships both sync and async Python APIs out of the box. Selenium remains the right choice for large legacy suites, Ruby or Kotlin teams, and compliance environments where W3C WebDriver standard backing matters.
Feature | Playwright | Selenium |
|---|---|---|
Best For | New projects, SPAs, Python/JS teams, AI workflows | Legacy suites, Ruby/Kotlin teams, W3C compliance environments |
Pricing | Free (Apache 2.0); cloud via Microsoft Playwright Workspaces | Free (Apache 2.0); cloud via Selenium Grid + BrowserStack/SauceLabs |
Python Support | Sync + async APIs | Sync only |
Architecture | CDP / persistent WebSocket | W3C WebDriver HTTP + BiDi (evolving) |
Auto-Waiting | Built-in (every action) | Manual waits required |
Setup Complexity | One-liner install, browsers bundled | Client bindings + separate driver download |
Language Support | JS/TS, Python, Java, C# | Java, Python, C#, JS/TS, Ruby, Kotlin |
GitHub Stars | 91,544 (June 2026) | 34,214 (June 2026) |
Speed vs Baseline | 44% faster on SPAs; 13% on server-rendered | Baseline |

Playwright is Microsoft's open-source browser automation framework, released January 31, 2020. It communicates directly with browser engines via native debugging protocols (CDP for Chromium, custom protocols for Firefox and WebKit) over a persistent WebSocket connection. That architecture eliminates the extra HTTP hop Selenium requires for every command, which is the root cause of Playwright's speed and reliability advantages.
By June 2026, Playwright had reached 91,544 GitHub stars, roughly 33 million weekly npm downloads (up from under 1 million in 2021), and a 94% retention rate in the State of JS 2024 survey. The npm figure reflects primarily JS/TS usage; the Python playwright package on PyPI adds uncounted installs on top of that.
WebDriverWait boilerplate required.
ThoughtWorks engineers built Selenium in 2004 as a browser automation library. Its WebDriver API routes every command through the W3C WebDriver HTTP protocol to a browser-driver binary (chromedriver, geckodriver), which then communicates with the browser. That architecture produced the W3C WebDriver standard that every major browser now ships; Selenium is the reference implementation.
By June 2026, Selenium was used by 15.4 million software developers worldwide and held 34,214 GitHub stars. Its npm weekly download figure (~2.1 million) understates actual usage. Selenium's Java, Python, Ruby, and C# bindings via Maven, PyPI, RubyGems, and NuGet account for the majority of installs and are not captured by the npm metric.
WebDriverWait + ExpectedConditions logic. Skipping one is the single most common source of flaky Selenium tests.A framing distinction most comparisons miss: "Playwright vs Selenium" is not an apples-to-apples comparison. Selenium WebDriver is a browser-control library; Playwright is an all-in-one test framework. The fair comparison is Playwright vs Selenium + pytest + Allure + Selenium Grid assembled together: factor that into setup and ongoing maintenance cost.
On r/softwaretesting, u/clearsurname (2026) frames the practical reality: "Tbh at this point I really feel like the only pro in the Selenium column is that it's easier to learn. Playwright does basically everything better. But at the end of the day, the biggest impact is HOW you write tests, not what you write tests with."
Playwright is faster. What most articles skip: the gap is application-architecture-dependent.
React SPA benchmark (Scrolltest, 250 E2E tests covering authentication, search, checkout, and admin, April 2026):
Metric | Playwright | Selenium |
|---|---|---|
Suite execution time | 3m 48s | 6m 52s |
Flakiness rate | 1.4% | 5.1% |
44% faster. 3.6 times fewer flaky tests on SPAs.
Server-rendered Java app benchmark (same CI runner, Scrolltest, April 2026):
Metric | Playwright | Selenium |
|---|---|---|
Suite execution time | 5m 10s | 5m 55s |
Flakiness rate | 1.8% | 2.3% |
Only 13% faster. Near-equivalent reliability. The application architecture matters as much as the framework choice, a nuance that disappears in most "Playwright is 2x faster" claims you'll read.
For sequential test suites, ARDURA Consulting's 3-way comparison placed Playwright at 3 minutes 20 seconds vs Selenium at 8 minutes 45 seconds. For simple page navigation, benchmarks show Playwright averaging ~290ms per action vs Selenium at ~536ms (Axelerant study, TestDino 2026).
Playwright also uses less memory per browser (2.1 GB vs 4.5 GB for 10 parallel tests, per TestDino 2026). Stability tracks the same direction: 92% for Playwright vs 72% for Selenium across 300+ test suites (Vervali Systems 2026).
The root cause is architecture. Playwright holds a persistent WebSocket connection to the browser engine with continuous DOM visibility. Selenium dispatches an HTTP request for every action, adding an HTTP round-trip per command; across a large test suite, those round-trips compound.
Winner: Playwright for SPAs and dynamic content. A tie on server-rendered apps.
Playwright setup in Python:
pip install playwright
playwright installDone. Browsers are bundled. Playwright includes a test runner, assertions, parallelism with workers and sharding, trace viewer, codegen (playwright codegen), screenshot/video capture on failure, and a VS Code extension.
Selenium setup in Python:
pip install selenium
# Plus: download ChromeDriver matching your installed Chrome version
# Selenium Manager (Selenium 4+) can automate driver downloadsSelenium is a client library. For testing, you also need pytest (or equivalent), an assertion library, a reporter (Allure, pytest-html), and Selenium Grid if you want parallelism. Setup takes longer and introduces more version-synchronization surface.
Feature | Playwright | Selenium |
|---|---|---|
Test runner | Built-in | Bring your own (pytest, JUnit) |
Assertions | Built-in | Bring your own |
Parallelism | Built-in workers + sharding | Selenium Grid (separate) |
Trace viewer | Built-in | Third-party |
Codegen | Built-in | Selenium IDE (separate tool) |
Network interception | Built-in | Selenium Wire (third-party) |
CI/CD scaffold | GitHub Actions scaffold included | Manual configuration |
Practitioners on r/selenium consistently describe the Selenium Grid parallel setup as taking 3 to 4 hours vs Playwright's "one or two minutes" with a config file. The library vs framework distinction makes that assembly cost concrete.
Winner: Playwright
Playwright's biggest developer-experience advantage for Python is auto-waiting combined with a native async API.
Auto-waiting removes the boilerplate:
# Selenium: explicit wait required before every critical interaction
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 10)
element = wait.until(EC.element_to_be_clickable((By.ID, "submit-button")))
element.click()
# Playwright: wait built into every action
await page.click("#submit-button") # waits for visibility, stability, and actionabilityJeff Nyman, a veteran test architect who has consulted for Fortune 500 QA teams, noted in a February 2026 analysis: "Playwright has essentially solved the flaky test problem at the framework level. The auto-wait mechanism and browser context isolation eliminate about 80% of the flakiness that teams typically experience with Selenium."
The async API enables concurrent workflows:
# Sync Playwright Python (straightforward scripts)
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
page.goto("https://books.toscrape.com")
titles = page.locator("h3 a").all_text_contents()
browser.close()
print(titles)
# Async Playwright Python (concurrent pipelines)
import asyncio
from playwright.async_api import async_playwright
async def scrape(url):
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True)
page = await browser.new_page()
await page.goto(url, wait_until="networkidle")
content = await page.content()
await browser.close()
return content
# Run multiple pages concurrently without spawning separate processes
results = await asyncio.gather(scrape(url1), scrape(url2), scrape(url3))Selenium has no async Python API. Concurrent execution requires Selenium Grid and separate processes with separate browser instances.
Playwright Python also cuts code: equivalent tasks run 30 to 50% shorter than Selenium equivalents across test and scraping scripts (per cross-framework migration case studies).
u/JAdcrendor in r/selenium (2025) describes the practical problem directly: "Speed and lack of locator options means without a mature shift left approach you can be stuck using xpath. Playwright solves both of these problems."
Winner: Playwright for Python developers starting new projects
Both tools work for scraping. The caveat most comparison articles skip entirely: both expose WebDriver automation artifacts that anti-bot systems detect.
Playwright advantages for Python scraping:
time.sleep() callsSelenium advantages for scraping:
The caveat both tools share:
Both Playwright and Selenium were designed for testing, not scraping. Standard WebDriver-based tools leave detectable automation artifacts that anti-bot systems identify. John Watson Rooney, in a YouTube tutorial with 47,000 views on this topic, puts it plainly:
"They're all designed for testing purposes... and unfortunately if we try to force using these tools we might have some success but the chances are the telltale signs are going to be given away and we're going to get blocked."
For production scraping pipelines where anti-bot detection is in play, the practitioner recommendation is driverless CDP tools: nodriver and selenium-driverless control your system-installed Chrome directly without the WebDriver detection surface. They avoid the automation flags both tools expose.
The practical split: use Playwright or Selenium for one-time JS rendering, cookie extraction, or scripted automation of a site you control. For ongoing production pipelines where blocking is a risk, driverless approaches are the recommended path.
Playwright's better developer ergonomics give it the edge for scripted Python scraping. But neither replaces purpose-built scraping infrastructure at scale.
Winner: Playwright for scripted scraping; nodriver / selenium-driverless for production pipelines
Browser support:
Browser | Playwright | Selenium |
|---|---|---|
Chrome / Chromium | Yes | Yes |
Firefox | Yes | Yes |
WebKit (Safari engine) | Yes | Yes (Selenium 4) |
Edge | Yes (Chromium-based) | Yes |
Internet Explorer | No | Yes (legacy) |
Real iOS Safari | Limited (emulation only) | Yes (via Appium) |
Legacy browser versions | No | Yes |
If legacy browser testing is a requirement, Selenium is your only option. Playwright's bundled browser builds are modified versions; they are not the exact browser binaries end-users run.
Language support:
Language | Playwright | Selenium |
|---|---|---|
JavaScript / TypeScript | Yes | Yes |
Python | Yes | Yes |
Java | Yes | Yes |
C# / .NET | Yes | Yes |
Ruby | No | Yes |
Kotlin | No | Yes |
If your team writes Ruby or Kotlin, Selenium is the only choice. Both Python and Java have full first-class bindings in Playwright.
Simon Stewart (@shs96c), Selenium's creator, articulates the speed philosophy Playwright has since built into its architecture:
@martinfowler @timbray @searls Also coming around to the idea of emphasising the speed of the feedback loop as the basis for a test pyramid: * Lots of very fast tests * Fewer slightly slower ones * Very few very slow tests The tighter we make feedback loops, the easier it is to iterate safely.
"Lots of very fast tests, fewer slightly slower ones, very few very slow tests. The tighter we make feedback loops, the easier it is to iterate safely."
Winner: Selenium for maximum language and legacy browser coverage. Playwright for Python, JS/TS, Java, and C# teams.
Playwright's biggest 2026 story is its expansion into AI-native tooling. This angle is absent from all 19 SERP results reviewed for this article.
In 2026, Playwright shipped:
npm i -g @playwright/cli@latest.test.abort(): an emergency stop for guardrail violations in autonomous agent flowsApplitools documented the practical developer impact on LinkedIn in June 2026:
"The true value of moving to Playwright is the dramatic reduction in repetitive structural code. Playwright's built-ins (auto-waiting, fixtures, trace tooling) instantly eliminate lengthy explicit waits and simplify state management, giving you cleaner code and predictable results."
Checkly's monitoring platform runs 123 live Playwright tests across Chromium, Firefox, and mobile Chrome in a single session with zero driver management. AI agents at companies like Checkly write Playwright tests, deploy them as production monitors via CLI, and receive root-cause analysis from AI reading Playwright traces, screenshots, and OpenTelemetry spans together.
Selenium's driver-based HTTP architecture does not compose cleanly with LLM code generation. WebDriver BiDi (the bidirectional WebSocket protocol that would close Selenium's capability gap) is being added incrementally; no public completion timeline exists. Selenium has no MCP server, no AI test agents, and no cloud testing service backed by a major cloud provider.
For Python developers building AI-augmented automation workflows in 2026, Playwright is the default choice.
Winner: Playwright
Both tools have a free entry point and pay-for-cloud options layered on top. Which costs more in practice depends on your cloud execution needs and existing infrastructure investments.
Choose Playwright if you are starting a new Python project in 2026, working with JavaScript-heavy SPAs or dynamic content, or need an async API for concurrent automation pipelines. It's also the right choice if you want built-in trace tooling and codegen without assembling a stack, or are building any AI-augmented workflow.
Choose Selenium if you maintain a large existing Selenium suite where migration cost outweighs the flakiness or speed gains, your team writes Ruby or Kotlin, or you need Internet Explorer or legacy browser coverage. Selenium is also the right choice when your environment requires W3C WebDriver compliance or you have Selenium Grid and BrowserStack/SauceLabs integrations already running in production.
The migration signal is telling. u/Darklights43 in r/softwaretesting (2025) searched for teams that had switched back from Playwright to Selenium and found no documented cases. "Kinda says it all to me," they concluded.
If you're working in Python and starting fresh, Playwright is the answer. Selenium earns its place in specific contexts, and those contexts are real, but new-project momentum has moved.

uv replaces pip, pyenv, virtualenv, pip-tools, and pipx with one Rust binary. Complete guide to installation, commands, Docker integration, and migration paths.

LangChain wins for stateful multi-agent orchestration and the broadest integration surface. LlamaIndex wins when retrieval accuracy over private documents is th

uv is 4–16× faster than Poetry and replaces 7 Python tools in one binary. Poetry still wins for PyPI library publishing. A 2026 decision guide.