Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 4 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

Playwright (JavaScript)

Check your site in real browsers.

TestingNPM

GitHubWebsite

1. License

“each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.”

Apache-2.0 allows commercial use at no charge.

github.com/microsoft/playwright/blob/main/LICENSE

From the package registry and GitHub, checked daily; card checked Nov 11, 2026. Tap a verdict to see its source.How we checkedReport an error

What Playwright (JavaScript) does

Playwright Test is Microsoft's free tool for testing a website or web app the way a visitor uses it. Your tests open real Chrome, Firefox and Safari-engine browsers, click, type and check what appears on the page. It runs on Windows, Mac and Linux, on your computer or on a build server.

What people build with it

Check the sign-up form works

Before each release, a test fills in your sign-up form like a visitor and checks the thank-you message appears.

Same test on three browsers

A layout bug that only shows in Safari or Firefox is caught before your visitors find it.

Start the app before testing

The test run starts your local dev server itself, waits for it, and then opens the pages.

Log in once for all tests

Tests behind a login do not each fill in the password form; they reuse a saved signed-in state.

See why a test failed on CI

When a test fails on the build server, you open a recording with each step, the page and the network calls.

Accessibility checks in the same run Idea

Add an accessibility scan to key pages with the axe-core add-on, so missing labels fail the test run.

Playwright (JavaScript) popularity

94 / 100
Gid Score, #4 overall
139M
downloads a week, npm
101K
GitHub stars
1,093
agent projects use it
Playwright (JavaScript): downloads per weeknpm, @playwright/test 138,786,046
Playwright (JavaScript): GitHub starsmicrosoft/playwright 100,939

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How Playwright (JavaScript) is used

  • Playwright (JavaScript) is a dependency in 1,093 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (22.5% of the 4,867 JavaScript/TypeScript ones), #2 of 122 in testing.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 2,160; those are left out of every share on this page.
  • The most used alternative in our scan is Vitest (1,312 projects).
  • Projects that use it most often also use Vitest (50.3%), TypeScript (76.9%), ESLint (58.3%).
  • It is more common in projects set up for OpenCode (24.8%) than for Devin Desktop (14.7%).

By coding agent

699 projects, 21.3%
547 projects, 18.0%
398 projects, 16.3%
109 projects, 23.2%
106 projects, 22.4%
85 projects, 24.8%
73 projects, 21.9%
41 projects, 14.7%

Often used with

In 50.3% of its projects
In 76.9% of its projects
In 58.3% of its projects
In 30.5% of its projects
In 41.2% of its projects
In 52.2% of its projects
In 51.2% of its projects
In 27.9% of its projects

Playwright (JavaScript) in practice

Strengths

Waiting is built into actions and assertions

The README says Playwright waits for elements to be actionable before it acts. Assertions retry until their condition is met, so tests don't need hand-written sleeps.

A fresh browser profile per test, with login saved once

Each test runs in its own browser context. You can save the logged-in state to a file with <code>storageState</code> and load it in other tests with <code>test.use</code>.

Trace Viewer records every step of a failed run

A trace holds DOM snapshots, network requests, console logs and screenshots for every action. The site says you can investigate a failure without running the test again.

Agents act on element refs, not pixels

Through MCP, the model gets an accessibility snapshot in which each element has a ref such as <code>e5</code>. It passes that ref to the next tool call. The docs say no screenshots or coordinate guessing are needed.

Watch out for

Browsers, not test code, set the speed limit

Endform, which sells a Playwright runner, writes that end-to-end suites are limited by the resources each browser consumes. Large suites end up sharded across machines.

MCP costs more context and opens a visible browser

The docs' own comparison rates MCP's token cost as higher than the CLI's, because tool schemas and snapshots sit in context. MCP also runs headed by default, while the CLI runs headless.

MCP exposes page-defined WebMCP tools unless you opt out

Since v1.64.0, Playwright MCP offers tools that a page registers through the experimental WebMCP API to the agent as <code>webmcp_&lt;tool&gt;</code>. Pass <code>--no-webmcp</code> to turn this off.

A first test with role-based locators

import { test, expect } from '@playwright/test';

test('has title', async ({ page }) => {
  await page.goto('https://playwright.dev/');
  await expect(page).toHaveTitle(/Playwright/);
});

test('get started link', async ({ page }) => {
  await page.goto('https://playwright.dev/');
  await page.getByRole('link', { name: 'Get started' }).click();
  await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
});

More about Playwright (JavaScript)

Agent Skills for it
  • : 18 Lessons to Get Started Building AI Agents
  • : Skills, MCP servers, Custom Agents, Agents.md for SDKs to ground Coding Agents
  • : A refined collection of Hypervelocity Engineering components (instructions, prompts, agents, and skills) to start your project off right, or
  • : CLI for testing and evaluating AI agent workflows, custom agents, and skills with repeatable scenarios, graders, evidence, and CI integratio
  • playwright-recording: Record browser interactions as video using Playwright. Use for capturing demo videos, app walkthroughs, and UI flows for Remotion videos. Tr
  • playwright-interactive: Persistent browser and Electron interaction through `js_repl` for fast iterative UI debugging.

See all

Packages around it
  • playwright: Library for browser automation scripts
  • @playwright/mcp: MCP server for AI agents
  • @playwright/cli: Browser CLI for coding agents
  • @playwright/experimental-ct-react: Experimental React component testing
  • @playwright/browser-chromium: Chromium browser download
  • @playwright/browser-webkit: WebKit browser download
More in Testing

Alternatives

Playwright (JavaScript) This page

Apache-2.0Gid 94139M/wk

Cypress

Pick Cypress if your team prefers its end-to-end runner and its way of writing tests.

Vitest

Pick Vitest for fast unit tests of functions and components; use Playwright for whole pages in a browser.

MITGid 86194M/wk

Playwright (Python)

Pick Playwright for Python when your tests or scripts are written in Python.

Jest

Delightful JavaScript testing framework with minimal configuration.

MITGid 8663.2M/wk

Compare Playwright (JavaScript) with another tool

Get started

Tell your AI assistant

“Add @playwright/test 1.65.0 as a dev dependency (Node 22+), run npx playwright install, write tests in tests/*.spec.ts with getByRole/getByLabel locators and await expect(...) assertions (no fixed waits), set webServer and baseURL in playwright.config.ts, and run npx playwright test.”

  1. Add it to a project and download the browsers it needs.

    npm i -D @playwright/test
    npx playwright install
    

    From github.com/microsoft/playwright/blob/main/README.md

  2. Write a test file in tests/ with test() and expect().

    import { test, expect } from '@playwright/test';
    
    test('has title', async ({ page }) => {
      await page.goto('https://playwright.dev/');
      await expect(page).toHaveTitle(/Playwright/);
    });
    

    From github.com/microsoft/playwright/blob/main/README.md

  3. Run all tests; open the report when something fails.

    npx playwright test
    npx playwright show-report
    

    From playwright.dev/docs/intro

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## Playwright
- Install with `npm i -D @playwright/test`, then run `npx playwright install` to download the browsers.
- Locate elements the way users see them: `getByRole`, `getByLabel`, `getByPlaceholder`, `getByTestId`. Avoid CSS paths.
- Do not add artificial timeouts. Use `await expect(...)` web-first assertions, which retry until the condition is met.
- Save login state once with `page.context().storageState({ path: 'auth.json' })` and reuse it with `test.use({ storageState: 'auth.json' })`.
- Set `trace: 'on-first-retry'` in `playwright.config.ts` and open failures with `npx playwright show-trace trace.zip`.
- To drive a browser yourself, prefer `playwright-cli`: its output is concise and keeps tool schemas out of context. Act on the element refs from the latest snapshot.

Mistakes to avoid

await page.waitForTimeout(3000) before checking the page
await expect(locator).toHaveText(...) and other web-first assertions

Assertions retry until the page is ready; fixed waits make tests slow and flaky.

npm i playwright @playwright/test (both packages)
npm i -D @playwright/test only

npx playwright test stops working when both are installed.

Upgrading @playwright/test without downloading new browsers
npm install -D @playwright/test@<version> && npx playwright install --with-deps

Every version needs its own browser builds; old ones do not match.

readonly submit = this.page.getByRole(...) as a class field in a page object (1.65+)
Assign the locator inside the constructor, or set useDefineForClassFields to false in tsconfig.json

Since 1.65 class fields follow tsconfig like tsc, so the field runs before the constructor sets page.

page.accessibility.snapshot() for accessibility tests
Use @axe-core/playwright, or locator.ariaSnapshot() for the accessibility tree

page.accessibility was removed after years of deprecation.

Questions

Do I need to add waits or sleeps?

No. Playwright waits for elements to be ready, and assertions retry until they pass or time out.

Should I install playwright and @playwright/test together?

No. Install only @playwright/test; it also exports the browser automation functions.

Can it check accessibility?

Not by itself any more; page.accessibility was removed and the docs point to Axe.

Can my company download the browsers from its own server?

Yes. Set PLAYWRIGHT_DOWNLOAD_HOST to an internal mirror before npx playwright install.

Does it run under Bun?

Since 1.65 the test runner can run under Bun with the --bun flag, with some features missing such as watch mode.

AgentGid articles about Playwright (JavaScript)

All guides