Selenium VS Playwright
This article compares the two automation libraries, focusing on what matters in day-to-day automation work.
Architecture
Selenium communicates with the browser through the WebDriver protocol. Each command is sent as an HTTP request to a browser-specific driver (such as ChromeDriver or GeckoDriver), which then controls the browser.
Playwright communicates with the browser over a persistent WebSocket connection, which enables faster and more reliable execution.
Waiting and Flakiness
Selenium has no built-in auto-waiting. Waits must be managed manually using implicit, explicit, or fluent waits, and poorly tuned waits are a common cause of flaky tests.
Playwright has built-in auto-waiting. Before acting on an element, it checks that the element is visible, enabled, stable, and actionable. Its web-first assertions also retry automatically until the condition is met or the timeout expires.
Browser Compatibility
Selenium supports Chrome, Firefox, Edge, Safari, and Internet Explorer.
Playwright supports Chromium, Firefox, and WebKit through bundled builds. It does not support real Safari or Internet Explorer, although WebKit closely approximates Safari’s behavior.
Language Support
Selenium supports Java, Python, C#, Ruby, JavaScript, and Kotlin.
Playwright supports JavaScript, TypeScript, Python, Java, and .NET.
Locators
Selenium: You can write more resilient tests using ID, CSS, and XPath.
Playwright: Can use locators (getByRole, getByLabel, getByText, getByTestId) with chaining and filtering that encourages more resilient selectors.
Test Runner
Selenium: No built-in test runner. But it can use TestNG, JUnit, Pytest, etc.
Get Tharushika Rathnayaka’s stories in your inbox
Join Medium for free to get updates from this writer.
Playwright: Has built-in ‘@playwright/test’
Parallelism
Selenium: Needs Selenium Grid or runner config
Playwright: Built-in, per-worker isolation
Tracing/video/screenshots
Selenium: Needs third-party libraries
Playwright: Built-in Trace Viewer, video, screenshots
Multiple tabs/contexts
Selenium: Window handles but clunky
Playwright: Browser contexts, lightweight and isolated
Auth state reuse
Selenium: Have to use manual cookie handling methods
Playwright: Built-in storageState
Mobile Emulation
Selenium: Limited
Playwright: Built-in device emulation
Recorder/IDE
Selenium: Selenium IDE
Playwright: Playwright Codegen







