Scrivio Interview library
ConceptIntermediate7 min read · updated 12 November 2026

Compare Selenium WebDriver and Playwright for Java for a new Spring Boot web application's UI tests. Cover waiting model, browser support, isolation, debugging tools and ecosystem.

Playwright for Java auto-waits for elements to be actionable and its assertions retry, gives each test a cheap isolated BrowserContext inside one browser, and has tracing, codegen and network interception built in, but it runs its own bundled Chromium, Firefox and WebKit builds tied to its version, and it follows the Node.js implementation. Selenium drives the real installed browsers, including real Safari, through vendor-implemented W3C drivers, needs explicit waits written by the tester, usually starts a browser per test, and has BiDi features, a long history, a wide skills base and a large ecosystem of tools and grid vendors.

Why this question is asked

Choosing a UI test tool for a new Spring Boot application is a decision a team lives with for years, so it is worth comparing on the points that affect daily work rather than on popularity. Interviewers ask this to see whether we can compare the two tools precisely, with the reasons behind each difference, and not just say that one is newer. In this answer, we will compare the waiting model, browser support, isolation, debugging tools and ecosystem, with a short code example for the biggest difference, and then say how we would choose.

1Waiting Model

Waiting is the biggest day-to-day difference. In Selenium, findElement and click act immediately. If the page is still loading or a button is still disabled, the test fails unless we wrote an explicit wait, a WebDriverWait with a condition such as elementToBeClickable. Testers must know where the page can change and add waits there, and missing one is the main source of flaky Selenium tests.

In Playwright, every action waits for actionability by default: click waits until the element is attached, visible, stable, enabled and not covered; fill waits until it is editable. Its web-first assertions, such as assertThat(locator).hasText("Saved"), retry until they pass or time out. Locators are re-evaluated on every use, so there are no stale references.

Java
// Selenium: we write the wait
new WebDriverWait(driver, Duration.ofSeconds(10))
.until(ExpectedConditions.elementToBeClickable(By.cssSelector("[data-testid=save]"))).click();
// Playwright: the wait is part of click()
page.getByTestId("save").click();
assertThat(page.getByTestId("status")).hasText("Saved"); // retries until it matches or 5 s pass

So Playwright reduces the wait code a team writes, and with it a large class of flakiness. It does not remove the need to think about application state, for example waiting for a background job, but it covers the common cases.

2Browser Support

Playwright downloads specific builds of Chromium, Firefox and WebKit that match each Playwright release, and drives them through its own protocol. Its Firefox and WebKit builds are patched by the Playwright team. That is why it can offer the same features on all three. The catch is that WebKit is the engine behind Safari, not Safari itself, and Playwright cannot drive the real Safari application or Safari on a real iPhone. It can also drive branded Chrome and Edge through a channel option.

Selenium drives the real browsers users have installed, through drivers the vendors build themselves to the W3C WebDriver standard: chromedriver from Google, geckodriver from Mozilla, msedgedriver from Microsoft, and safaridriver from Apple, which ships with macOS. So if real Safari matters, Selenium can test it directly, and through Appium, which speaks the same protocol, real mobile browsers too.

3Isolation

Playwright's BrowserContext is an isolated session inside one running browser, with its own cookies, storage and permissions. Creating one takes milliseconds, so the normal pattern is one browser per worker and one fresh context per test, which is both fast and clean.

Selenium typically starts a new browser session per test for clean state, which costs a second or more each time, more on a remote grid. We can reuse a session and clear cookies and storage between tests, but that is less thorough. On a grid, the per-test session is the price of isolation, and it scales by adding nodes.

4Debugging Tools

Playwright ships its debugging tools with the library. Tracing records every action with DOM snapshots before and after, network requests, console messages and screenshots into a zip that the trace viewer replays step by step. Codegen opens a browser, records our clicks and generates test code with good locators. Network interception with page.route lets a test mock or modify any request in a few lines.

Selenium provides the essentials, screenshots, logs and remote sessions, and with WebDriver BiDi it is adding standard network interception, console log listening and other event-based features on Chrome and Firefox. Many richer tools come from the ecosystem rather than the core: reporting libraries, grid vendors with video and dashboards, and IDE plugins.

5Ecosystem and Skills

Selenium has been the standard for well over a decade. Most testers know it, most cloud browser vendors are built around it, and nearly every question has an answer somewhere. Its Java bindings are first-class, and frameworks, grids and reporting tools assume it.

Playwright is newer and its main implementation is in Node.js. The Java version is an official port that bundles a Node-based driver process; features usually appear in the Node version first and reach Java a little later, and some test-runner conveniences of the Node version, such as its built-in runner, have no direct Java equivalent, so Java teams pair it with JUnit. Its community is growing quickly.

Selenium WebDriver and Playwright for Java
AspectSelenium WebDriverPlaywright for Java
WaitingExplicit waits written by the testerAuto-wait on actions, retrying assertions
BrowsersReal installed browsers incl. SafariBundled Chromium, Firefox, WebKit builds
ProtocolW3C WebDriver, BiDiPlaywright's own protocol
IsolationUsually a browser session per testCheap BrowserContext per test
DebuggingScreenshots, logs, BiDi events, vendor toolsTrace viewer, codegen, route() built in
EcosystemLong history, many grids and vendorsGrowing; Node.js gets features first

6How We Would Choose

For a new Spring Boot application whose users are mostly on Chromium and Firefox, Playwright is often the faster path to a reliable suite, because of auto-waiting, contexts and tracing. If real Safari or real mobile browsers are a requirement, or the company already runs a Selenium grid or vendor and has page object libraries and skills, Selenium is the safer choice. Either way, the test design, stable locators, page objects and API-created data, matters more than the tool, and it is what makes a later switch affordable.

7Follow-up questions

Which would you choose for testing on real iOS Safari?

Selenium, or more precisely the WebDriver ecosystem. Playwright's WebKit build shares Safari's engine but is not Safari, and it cannot run on a real iPhone. For desktop Safari, Selenium uses safaridriver on macOS. For Safari on iOS, we use Appium with its XCUITest driver, which speaks the WebDriver protocol, on real devices or simulators, usually through a cloud device vendor because owning iPhones and Mac hosts is expensive. Many teams run most tests in Playwright or Selenium on Chromium and keep a smaller set of journeys on real iOS Safari through Appium.

Can Playwright test a Spring Boot app started by the test?

Yes. With @SpringBootTest(webEnvironment = RANDOM_PORT) we inject the port with @LocalServerPort and navigate Playwright to http://localhost:port. The same works for Selenium. It is a good setup for a small number of end-to-end tests that need the real application.

Is Playwright faster than Selenium?

Often in practice, mainly because contexts are cheaper than new browser sessions and because auto-waiting avoids fixed sleeps. A well-written Selenium suite on a good grid can be fast too; the difference is smaller than pilots between a new Playwright suite and an old Selenium one suggest.

8Conclusion

In this answer, we compared Selenium WebDriver and Playwright for Java. Playwright auto-waits and retries assertions, isolates tests with cheap browser contexts, and builds in tracing, codegen and network interception, but uses its own bundled browser builds, including WebKit rather than real Safari, and follows its Node.js implementation. Selenium drives the real browsers through vendor W3C drivers, needs explicit waits, usually uses a session per test, and has BiDi features and a much larger ecosystem and skills base.

What to say in the interviewAbout 90 seconds aloud

Open with

I would compare them on five points. First, waiting: in Selenium I write explicit waits with WebDriverWait wherever the page can change, which is where most flakiness comes from, while Playwright's actions wait automatically until the element is visible, stable, enabled and not covered, and its assertions retry, so there is much less wait code and no stale element problem.

Then, if they want more

Second, browsers: Playwright downloads its own Chromium, Firefox and WebKit builds tied to its version, so WebKit is not real Safari; Selenium drives the real installed browsers through drivers the vendors build to the W3C standard, including safaridriver for real Safari, and Appium for mobile.

Third, isolation: Playwright creates a BrowserContext per test in milliseconds inside one browser, while Selenium usually starts a new browser session per test, which is slower but simple.

Fourth, debugging: Playwright has tracing with a trace viewer, codegen and network interception built in; Selenium has screenshots and logs, BiDi for network and console events, and a large set of third-party tools and grid vendors.

Fifth, ecosystem: Selenium has a long history, a wide skills base and first-class Java bindings, while Playwright for Java is an official port where features usually land in Node.js first. For a new Spring Boot app mostly used on Chromium and Firefox, I would lean to Playwright.

If real Safari or mobile is required or we already have a Selenium grid and skills, I would choose Selenium.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Compare Selenium WebDriver and Playwright for Java for a new Spring Boot web...": https://scrivio-interview-library.netlify.app/java/ui-testing/3464635561/