Playwright is an open-source end-to-end testing framework from Microsoft that drives Chromium, Firefox and WebKit through a single API. It communicates with browsers over their native debugging protocols using a persistent WebSocket connection, rather than through the HTTP-based WebDriver protocol Selenium uses.
Selenium sends each command as a separate HTTP request to a WebDriver server (e.g. chromedriver), which translates it for the browser. Every command is a round trip, and the driver is a separate binary you must version-match to the browser. Playwright instead speaks each browser's own DevTools-style protocol over one long-lived WebSocket connection, so commands are lower-latency and it can observe browser events (network, console, dialogs) directly. Playwright also introduces the concept of a BrowserContext — an isolated, incognito-like session inside a single browser process. Contexts are cheap to create, so each test can get a fresh, cookie-free environment in milliseconds instead of launching a whole new browser. This architecture is why Playwright ships auto-waiting, network interception and multi-tab handling as first-class features, whereas in Selenium they require extra libraries or manual work.
A team runs the same login regression across Chrome, Firefox and Safari. With Selenium they maintain chromedriver, geckodriver and safaridriver, keep each in step with browser updates, and hit WebKit only on macOS. With Playwright, one npx playwright install pulls pinned Chromium, Firefox and WebKit builds, and the same test runs on all three from any OS — WebKit included on Linux CI.
| Aspect | Selenium | Playwright |
|---|---|---|
| Browser communication | HTTP WebDriver, per-command | Persistent WebSocket / CDP-style |
| Drivers | Separate driver per browser, version-matched | Bundled, pinned browser builds |
| Isolation unit | New browser session | BrowserContext (fast, in-process) |
| Waiting | Manual explicit/implicit waits | Automatic auto-waiting |
| Cross-browser WebKit | Safari on macOS only | WebKit engine on any OS |
Scenario: In an interview you're asked why Playwright tends to be faster and less flaky than an equivalent Selenium suite, purely from an architecture standpoint. How do you answer without just saying 'it's newer'?
If asked the single biggest difference, lead with auto-waiting + BrowserContext isolation — those two explain most real-world stability differences.