Testing web applications

Playwright or Selenium: which is better suited to your project?

For a new web project with a team that knows JavaScript or TypeScript, Playwright Test is worth trying. If you already have a maintained Selenium suite that covers the required browsers and reliably catches defects, continuing with it may be the better choice. Let the specific problem and a small comparison guide the decision, rather than the tool’s popularity.

Both tools automate interactions with a web browser. The quality of the result also depends on what the test checks, the data it uses and whether the team can explain a failure. Replacing the library will not fix a test that checks the wrong outcome.

Start with the problem you need to solve

Before choosing a tool, review recent test failures. Do tests fail after interface changes, wait for the wrong condition or overwrite each other’s data? Are you missing a particular browser, a useful report or someone who understands the existing suite?

These causes lead to different decisions. You can fix an unstable selector, the way a test finds a page element, in either tool. Two tests conflicting over the same account require a change to data setup. Missing coverage of real Safari is a browser and environment requirement. If the problem lies in the suite’s foundations, first assess whether to repair or rewrite it.

For a new project, list the required browsers, test language, execution process and responsibility for maintenance. For an existing suite, add the useful coverage it already provides. The number of files says little about which defects the suite can detect.

Compare the whole setup, including the test framework

Playwright has libraries for Node.js, Python, Java and .NET. Playwright Test is a test runner for Node.js that runs and evaluates tests. It includes web assertions, which check expected outcomes, parallel execution and an HTML report. In Java you can use JUnit, for example, and in Python the recommended pytest plugin. A shared automation core does not mean identical test organisation and reporting in every language. Playwright’s supported languages.

Selenium WebDriver controls the browser through the WebDriver interface, locally or remotely. You choose the test framework, reporting and suite structure according to your language and existing setup. When comparing Selenium with Playwright Test, account for the other tools in the test suite as well. Selenium WebDriver documentation.

Project need What to check with Playwright What to check with Selenium
Language and team The relevant language library or Playwright Test for Node.js Existing language, framework and team knowledge
Browsers Bundled versions and supported Chrome/Edge channels Specific browsers, drivers and operating systems
Waiting Checks before an action and the expected outcome Explicit conditions and configured timeouts
Diagnostics Trace configuration and report retention Framework reports and available diagnostic evidence
Remote execution Support in the chosen infrastructure Compatible Grid nodes and their operation

WebKit is not Safari, and emulation is not a phone

Playwright uses specific versions of Chromium, Firefox and WebKit. Its bundled Firefox and WebKit contain patches required for automation. They are not interchangeable with an arbitrary installed version of Firefox or Safari. Playwright also supports selected channels of branded Chrome and Edge. After upgrading the library, you may need to install new bundled browsers. Browser support.

A WebKit result is useful for checking that engine, but do not record it as a test of a particular Safari version. If you guarantee desktop Safari support to customers, include the actual browser and macOS in your verification plan. Selenium uses SafariDriver, which ships with macOS and requires automation to be enabled. Safari in Selenium.

In your support matrix, specify the browser brand, version and operating system you actually need. Saying that you test three browsers can hide a gap between the customer’s requirement and what runs in continuous integration (CI), where automated project checks are executed.

Playwright’s mobile emulation sets properties such as viewport size, user agent and touch input. It helps check how the website behaves with those settings. It does not verify behaviour on a physical phone, the full mobile operating system or a native app. If you need that coverage, assess the devices, tooling and execution process separately. Emulation scope.

Wait for the state you need to verify

Before clicking, Playwright checks that the chosen selector matches exactly one element and that it is visible, stable, enabled and receives events. It waits up to the configured timeout. This helps with dynamic interfaces, but does not confirm that an operation has completed on the server. Checks before an action.

After clicking to submit an order, verify the agreed outcome. Playwright Test’s web assertions repeatedly check conditions such as the expected text until it appears or the timeout expires. The test author still has to choose the correct condition. Playwright Test assertions.

Selenium can also wait for application state. An explicit wait specifies a condition, such as a button being ready or the expected confirmation appearing. Implicit waiting when finding an element does not replace all these conditions. The documentation advises against mixing implicit and explicit waits because the resulting wait times can be unpredictable. Selenium waiting strategies.

If the suite uses fixed pauses, compare them with waiting for a specific state in the pilot. A longer pause can increase runtime and still fail to handle a slower response. Evaluate retries of the whole test separately. A successful retry does not explain the original failure.

Diagnostics and CI affect everyday work

Playwright Trace Viewer lets you inspect recorded steps, page state snapshots and network requests. You must configure both recording and retention. After a failure, the team may be able to see what the test clicked and which state it encountered. A trace alone does not establish whether the defect is in the application, test or environment. Trace Viewer.

Selenium result reporting relies on the chosen test framework and CI integration. Check which evidence you already collect and what needs adding. A missing report in a particular suite does not prove that Selenium cannot provide useful diagnostics. Reporting Selenium test results.

Selenium Grid routes tests to remote browsers and supports parallel execution on different machines. You must have the required browser and operating system combinations available, with compatible drivers. Running Grid is part of the cost even if you already use it. Selenium Grid.

Playwright also has an experimental connection to Selenium 4 Grid, documented for Chrome and Edge through the Chrome DevTools Protocol (CDP). Do not treat it as a general solution for every Playwright browser. For other remote providers, verify their own support. Connector requirements.

For both setups, check access to the application under test, accounts, CI capacity and artifact retention. Playwright also needs the required browsers and system dependencies installed. Running in CI.

Compare the tools with the same small pilot

As an illustrative pilot, use an order containing one product. Include login, product selection, confirmation and verification of the saved order. Add a variant with a missing required field and the agreed rejection behaviour, where no new order is created. This lets you compare element loading, validation and the actual outcome of the operation.

  1. Agree on the same expectations. Success means an order with the correct product, quantity and user. A confirmation message alone is insufficient. Verify the saved state through an approved API or by reopening the details, depending on what the application supports.
  2. Prepare separate data. Each run needs its own account or a safely isolated cart and order, a test product and cleanup rules. Disable real payments in the test environment. Even an isolated browser context does not automatically separate shared server data.
  3. Run under comparable conditions. Use the same application version, comparable CI resources and the same supported browser and version. Record the browser version, timeouts and retries. Treat results from real Safari and bundled WebKit as different coverage.
  4. Check that the tests detect a defect. In a separate, controlled application build, deliberately keep the success confirmation but omit saving the order. Both tests should fail when checking the outcome. If they stay green, fix their checks before comparing tools.
  5. Measure the work as well as runtime. Record time spent on implementation, data preparation, failure diagnosis and test changes after an interface change. Track machine runtime separately. Record first-attempt failures as well as repeated runs so that retries do not hide problems.

Playwright Test isolates browser storage by default through separate contexts. When using the library, you create contexts as needed. Selenium also recommends independent tests. In both cases, the team remains responsible for server data setup. Playwright isolation, Selenium test independence.

Include migration and maintenance in the cost

Playwright and Selenium both use Apache License 2.0. The tools themselves do not require a paid licence. This does not remove the cost of cloud browsers, infrastructure, implementation or maintenance. Playwright licence, Selenium licence.

For a migration, include rewriting helpers, data setup and reports, changing CI, training the team and maintaining two suites during the transition. Check scenarios that the pilot did not cover as well. A short, successful comparison will not reveal every issue in a large suite.

A gradual migration from Selenium to Playwright lets you keep useful existing coverage while verifying the new tests. Carry over the expected behaviour and the purpose of each scenario, then adapt selectors and waits to the new tool. Retire an existing test only after its replacement has been accepted and an owner assigned.

For a new project, choose a setup that covers the required environments and that the team can maintain. For an existing project, a change makes sense when the pilot shows a specific benefit worth the migration cost. If the cause of the problems still lies in the data or test expectations, fix those foundations first.

Related topics

You might also be interested in

Catch bugs before they reach users

End-to-end tests of key scenarios can run automatically in CI/CD to catch bugs before they reach customers.