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/LICENSE3. Used by agents' projects
Dependency in 1,093 public GitHub projects set up for AI coding agents that we scanned (17.5%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
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
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
Often used with
Playwright (JavaScript) in practice
Strengths
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.
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>.
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.
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
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.
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.
Since v1.64.0, Playwright MCP offers tools that a page registers through the experimental WebMCP API to the agent as <code>webmcp_<tool></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.
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
Alternatives
Playwright (JavaScript) This page
Pick Cypress if your team prefers its end-to-end runner and its way of writing tests.
Pick Vitest for fast unit tests of functions and components; use Playwright for whole pages in a browser.
Pick Playwright for Python when your tests or scripts are written in Python.
Delightful JavaScript testing framework with minimal configuration.
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.”
Add it to a project and download the browsers it needs.
npm i -D @playwright/test npx playwright installWrite 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/); });Run all tests; open the report when something fails.
npx playwright test npx playwright show-report
Rules for your agent
## 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
Assertions retry until the page is ready; fixed waits make tests slow and flaky.
npx playwright test stops working when both are installed.
Every version needs its own browser builds; old ones do not match.
Since 1.65 class fields follow tsconfig like tsc, so the field runs before the constructor sets page.
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.