Selenium has been around since 2004. It is battle-tested and supports every browser and language. But it was designed for a different era of web applications. Modern SPAs with dynamic rendering, shadow DOMs, and heavy JavaScript expose Selenium weaknesses.
| Feature | Playwright | Selenium |
|---|---|---|
| Architecture | Direct browser protocol (CDP/custom) | WebDriver protocol via driver binary |
| Auto-Wait | Built-in. Every action waits automatically | Manual. Need explicit waits everywhere |
| Browser Install | npx playwright install (managed) | Download matching driver manually |
| Speed | Fast -- no HTTP roundtrips to driver | Slower -- every command is an HTTP request |
| Multi-tab Support | Native. First-class API | Hacky. Switch between window handles |
| iFrame Support | frameLocator() -- clean API | switchTo().frame() -- error-prone |
| Shadow DOM | Pierces shadow DOM by default | Requires special handling |
| Parallel Execution | Built into test runner | Requires TestNG/JUnit + Grid setup |
| Trace Viewer | Built-in GUI with screenshots + network | No equivalent (use screenshots manually) |
| Language Support | TS, JS, Python, Java, C# | Java, Python, C#, Ruby, JS, Kotlin |
| Community Size | Growing fast (60k+ GitHub stars) | Massive (30k+ GitHub stars, 20 years) |
Q: Why would you choose Playwright over Selenium for a new project?
A: Three reasons. First, auto-wait eliminates 80% of flaky test issues -- every action waits for the element to be actionable without explicit waits. Second, direct browser communication via CDP is faster than Selenium's HTTP-based WebDriver protocol. Third, the built-in test runner handles parallel execution, retries, and HTML reporting without additional setup. Selenium needs TestNG + Grid + ReportNG to match what Playwright ships out of the box.
Key Point: Playwright beats Selenium on speed, reliability, and developer experience. Selenium wins on ecosystem maturity and language breadth.