Taiab's Blog

Playwright vs Selenium: Which I Reach For and Why

Md. Taiab

Md. Taiab

2024-11-19 ยท 2 mins read


I started automation with Selenium WebDriver and later moved most new work to Playwright. Both are good. They're good at different things.

Where Selenium Still Wins

  • Real browser/grid diversity: if you need to test on a specific old Safari or a vendor cloud grid, Selenium's ecosystem is unmatched.
  • Language spread: mature bindings for Java, Python, C#, Ruby, JS โ€” useful when your team isn't JS-first.
  • Existing investment: a large, stable Selenium suite is not worth rewriting just for fashion.

Where Playwright Wins

  • Auto-waiting: it waits for elements to be actionable before interacting, which kills a whole class of flaky sleep() hacks.
  • Speed: it drives the browser over the DevTools protocol, not the slower WebDriver wire protocol.
  • Built-in superpowers: network interception, tracing, video, and parallel isolation come in the box.

The Flakiness Difference

This is the practical one. In Selenium I wrote a lot of explicit waits:

new WebDriverWait(driver, Duration.ofSeconds(10))
    .until(ExpectedConditions.elementToBeClickable(button));
button.click();

In Playwright the wait is implicit:

await page.getByRole('button', { name: 'Submit' }).click();

The locator retries until the element is actionable or it times out. Fewer waits means fewer flaky failures, which means people actually trust the suite.

My Default Now

For a new project with a JS/TS team, I start with Playwright โ€” the flakiness savings alone justify it. For a team standardized on Java with a working grid, I stay on Selenium. The framework that your team will maintain beats the framework that benchmarks best.

The Part Neither Solves

Both let you write brittle, over-coupled tests. Locator strategy, test isolation, and not asserting on volatile UI text matter more than the tool. A disciplined Selenium suite beats a careless Playwright one every time.

Md. Taiab

Written by Md. Taiab

Follow

Md. Taiab is a Software QA Engineer and security enthusiast based in Dhaka, Bangladesh. He interned as a QA Engineer at Battery Low Interactive Ltd. and competes in CTFs and programming contests โ€” ranked Top 3% globally on TryHackMe and Champion of GUB Junior IDPC 2023.

Comments disabled โ€” add your CommentBox.io project ID to .env.local as NEXT_PUBLIC_COMMENTBOX_ID