Skip to main content
Playwright and Selenium are the two most widely used open-source frameworks for browser automation. Both drive real browsers and support multiple languages, but they take different approaches: Playwright ships a complete testing toolkit, while Selenium provides a standards-based automation layer that you combine with the test framework of your choice. This article compares the two to help you decide which fits your project.

Playwright overview

Playwright is a browser automation framework maintained by Microsoft. It supports JavaScript/TypeScript, Python, Java, and .NET. The Node.js version includes Playwright Test, a full test runner. Other languages integrate with their standard test frameworks, such as pytest, JUnit, TestNG, NUnit, MSTest, and xUnit.

Playwright key features

  • Built-in test runner: Playwright Test handles test execution, parallelism, retries, fixtures, assertions, and reporting.
  • Auto-waiting: Locators wait for elements to be actionable before interacting, and web-first assertions retry until they pass or time out.
  • User-facing locators: Locators such as getByRole, getByLabel, and getByText find elements the way users and assistive technology see them.
  • Cross-browser testing: Runs Chromium, Firefox, and WebKit, plus branded Google Chrome and Microsoft Edge.
  • Isolation: Each test runs in its own lightweight browser context, so tests don’t share cookies or storage.
  • Debugging tools: Trace Viewer, UI Mode, and the HTML reporter show every action, DOM snapshot, network request, and console message from a run.
  • Beyond UI testing: Built-in API testing, network interception and mocking, screenshot and ARIA snapshot assertions, and device emulation.
  • AI tooling: The Playwright MCP server lets AI agents drive a browser, and Playwright Test Agents plan, generate, and repair tests.

Run a Playwright test

  1. Set up Playwright Test in your project. The installer adds the dependencies, a config file, and the browsers:
  2. Write a test in the tests folder:
    tests/example.spec.ts
  3. Run the test with the Playwright CLI:

Selenium overview

Selenium has been a mainstay of browser automation for more than two decades. Its WebDriver protocol became a W3C standard, and browser vendors ship their own drivers for it. Selenium supports Java, Python, C#, Ruby, and JavaScript. Selenium is a browser automation library rather than a test framework. You pair it with a test runner such as JUnit, TestNG, pytest, NUnit, or Mocha for assertions, reporting, and parallel execution.

Selenium key features

  • Multi-language support: Official bindings for Java, Python, C#, Ruby, and JavaScript.
  • Cross-browser testing: Works with Chrome, Firefox, Edge, and Safari through vendor-maintained drivers.
  • Automatic driver management: Selenium Manager, included with Selenium, downloads the right driver, and the browser if needed, so there’s no manual driver setup.
  • W3C standards: Built on the WebDriver standard. Selenium also supports WebDriver BiDi, the bidirectional successor standard, for features such as console logs and network interception.
  • Selenium Grid: Runs tests in parallel across many machines, browsers, and operating systems.
  • Mobile and real devices: Appium extends the WebDriver protocol to native and mobile web testing on real iOS and Android devices, and cloud testing providers run Selenium tests on real browsers and devices.
  • Selenium IDE: A browser extension for Chrome and Firefox that records and plays back tests.
  • Large ecosystem: Many plugins, integrations, and learning resources built over the project’s history.

Run a Selenium test

Here’s how to run a Selenium test in Node.js:
  1. Install Selenium WebDriver:
  2. Write a script that opens a browser, checks the page title, and closes the browser:
    test.js
  3. Run the script:
For larger suites, run Selenium from a test framework such as Mocha to get test organization, reporting, and retries.

Playwright vs Selenium: key differences

Both tools automate real browsers, but their architecture and scope differ.

Side-by-side example

The following tests log in to a service, open recent transactions, and take a screenshot.

Selenium

Playwright

Key differences between the two examples:
  • Locators: Playwright finds elements by role and label, the way users see them. IDs and classes can change during a visual redesign even when the page works the same, which breaks tests that depend on them.
  • Waiting: Playwright waits for the button to be actionable before clicking, and the toBeVisible assertion retries until the transactions appear. In Selenium, you add explicit waits for each element that loads asynchronously.
  • Lifecycle: Playwright Test launches and closes the browser for you and reports failures. The Selenium script manages the driver itself.

Playwright vs Selenium: pros and cons

Playwright

Pros: Quick setup, complete built-in test tooling, auto-waiting, strong debugging with Trace Viewer, built-in API testing and network mocking, and fast, isolated parallel execution. Cons: No official Ruby bindings, the full Playwright Test runner is Node.js only, WebKit approximates Safari rather than running it, and no real iOS device testing.

Selenium

Pros: W3C standard protocol, runs the browsers your users have including Safari, supports more languages, scales across machines with Selenium Grid, and connects to real devices through Appium. Cons: Requires assembling a test framework, assertions, and reporting yourself, explicit waits add code and a source of flakiness, and debugging tools are more limited.

Playwright vs Selenium: which to choose?

When to use Playwright

  • You’re starting a new project and want to be productive quickly.
  • Your team works in JavaScript/TypeScript, Python, Java, or .NET.
  • You want built-in auto-waiting, tracing, visual comparisons, API testing, and network mocking.
  • You plan to use AI agents to write, run, or fix tests.

When to use Selenium

  • You have an established Selenium suite and the infrastructure around it.
  • Your team works in Ruby, or already uses a Selenium-based framework.
  • You need to test on real iOS or Android devices, or in Safari itself.
  • You run large, distributed suites on Selenium Grid or a Selenium-based cloud provider.

Conclusion

If you’re starting a new project, choose Playwright. You get a complete testing toolkit from a single install, and auto-waiting, user-facing locators, and Trace Viewer make tests more reliable and easier to debug. If you already use Selenium, it remains a capable, standards-based framework. You don’t need to rewrite a working Selenium suite just to adopt Playwright. You can write new tests in Playwright and migrate existing ones gradually. Checkly runs Playwright tests as monitors, so the same tests you write for CI can check production around the clock. See Playwright Check Suites to get started.