# Playwright

URL: https://softwaredictionary.org/terms/playwright
Category: Testing & Quality
Last updated: 2026-10-03
Pronunciation: PLAY-rite

In short: Playwright is Microsoft's open-source framework for end-to-end testing and browser automation, driving Chromium, Firefox and WebKit through one API.

## What is Playwright?

Playwright was released by Microsoft in 2020, built by engineers who had earlier created Puppeteer at Google. It controls real browsers, Chromium for Chrome and Edge, Firefox, and WebKit, the engine behind Safari, so a single test can check that a sign-up or checkout flow works the same everywhere. Tests can be written in JavaScript or TypeScript, Python, Java or .NET.

A test opens a page, finds elements and acts on them as a user would: clicking, typing, choosing from menus and uploading files. Locators such as `getByRole("button", { name: "Sign in" })` find elements the way people and screen readers see them, which keeps tests stable when the markup changes. Before every action, Playwright waits automatically until the element is visible and enabled, which removes most of the timing problems that make browser tests flaky.

Playwright Test, its built-in test runner, runs tests in parallel, emulates phones and screen sizes, can intercept network requests and compares screenshots. When a test fails on CI, the trace viewer replays every step with screenshots, DOM snapshots and network calls. A code generator can record clicks in a browser and turn them into a test.

A common misconception is that Playwright replaces unit tests. End-to-end tests are slower and check whole user journeys, so they sit at the top of the test pyramid; fast unit and integration tests should still cover most of the logic. Compared with Selenium and Cypress, Playwright is newer and supports multiple browsers, tabs and origins in one test out of the box.

## Key takeaways

- Playwright automates Chromium, Firefox and WebKit through one API.
- Role-based locators find elements the way users see them.
- Auto-waiting before every action reduces flaky tests.
- Its test runner adds parallel runs, device emulation, screenshots and traces.
- End-to-end tests complement, not replace, unit and integration tests.

## Example: An end-to-end test of a sign-in flow

```typescript
import { test, expect } from "@playwright/test";

test("a user can sign in", async ({ page }) => {
  await page.goto("https://example.com/login");

  await page.getByLabel("Email").fill("ada@example.com");
  await page.getByLabel("Password").fill("correct horse battery");
  await page.getByRole("button", { name: "Sign in" }).click();

  // Waits automatically until the heading appears
  await expect(page.getByRole("heading", { name: "Welcome, Ada" })).toBeVisible();
});
```

## Frequently asked questions

**What is the difference between Playwright and Selenium?**

Both automate real browsers. Selenium is older, uses the WebDriver standard and supports many languages and browsers. Playwright talks to browsers more directly, waits automatically and includes a modern test runner, tracing and network control.

**What is the difference between Playwright and Cypress?**

Cypress runs tests inside the browser and is known for its interactive runner. Playwright controls browsers from outside, which makes multiple tabs, origins and browsers, including WebKit, straightforward.

**Can Playwright be used for things other than testing?**

Yes. It is also used for browser automation in general, such as taking screenshots, generating PDFs and scraping pages, and by AI agents that operate websites.

---

Software Dictionary: https://softwaredictionary.org/ · https://softwaredictionary.org/llms.txt
