# Playwright (JavaScript) — card for AI agents

Cross-browser automation library for end-to-end testing.

Category: Testing · npm package `@playwright/test` · latest version 1.64.1 (checked 2026-11-01)
Install: `npm install @playwright/test`
License: Apache-2.0 (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (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.

## Agent Skills for it
- Official: microsoft/ai-agents-for-beginners (6 skills): `npx skills add microsoft/ai-agents-for-beginners`
- Official: microsoft/skills (213 skills): `npx skills add microsoft/skills`
- Official: microsoft/hve-core (97 skills): `npx skills add microsoft/hve-core`
- Official: microsoft/waza (38 skills): `npx skills add microsoft/waza`
- playwright-recording from OpenMontageInc/OpenMontage: `npx skills add OpenMontageInc/OpenMontage --skill playwright-recording`
- playwright-interactive from openai/skills: `npx skills add openai/skills --skill playwright-interactive`
- playwright-expert from Jeffallan/claude-skills: `npx skills add Jeffallan/claude-skills --skill playwright-expert`
- playwright-skill from tech-leads-club/agent-skills: `npx skills add tech-leads-club/agent-skills --skill playwright-skill`
- playwright-best-practices from midudev/autoskills: `npx skills add midudev/autoskills --skill playwright-best-practices`
- playwright-skill from zebbern/claude-code-guide: `npx skills add zebbern/claude-code-guide --skill playwright-skill`

## What it is
- Playwright is Microsoft's framework for web automation and testing. The repository dates from November 2019 and is Apache-2.0 licensed. Its README says it drives Chromium, Firefox and WebKit "with a single API — in your tests, in your scripts, and as a tool for AI agents." This profile covers `@playwright/test`, the test runner. It runs tests in parallel across the configured browsers and is headless by default. Each test gets its own browser context.
- The same engine also ships as `playwright`, a library for scripts that take screenshots, make PDFs or scrape pages without a test runner. The project also offers a VS Code extension for running, debugging and recording tests.
- Agent tooling is the newer part. `@playwright/cli` is aimed at coding agents such as Claude Code and Copilot. `@playwright/mcp` is a Model Context Protocol server for agentic loops. In both, the agent reads the page as an accessibility tree and acts on element refs rather than screenshots.

## Caveats
- 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 `webmcp_<tool>`. Pass `--no-webmcp` to turn this off.
- Video frame rate is capped outside Chromium: The v1.64.0 release added a custom `fps` option for video. The release notes say Firefox and WebKit capture at most 25 frames per second.
- Video `fontSize` is deprecated: The new `style` option takes CSS for the action decorations in recorded videos. It replaces the `fontSize` option, so configs that use `fontSize` need updating.

## Numbers (AgentGid data)
- Gid Score: 93.5 (#4 of all tools, 1 of 122 in its category)
- Used in 1,093 public projects set up for AI coding agents (17.5%)
- Downloads last week: 138,786,046 (as of 2026-11-24), +67.9% over 4 weeks
- GitHub stars: 100,939 (as of 2026-11-24)
- Last push: 2026-11-24

## Often used with
Vitest 50.3%, TypeScript 76.9%, ESLint 58.3%, Testing Library 30.5%, Vite 41.2%, Tailwind CSS 52.2%

## Checked alternatives (same job)
- Vitest: https://agentgid.com/tools/vitest/agent.md
- Jest: https://agentgid.com/tools/jest/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/playwright-test/
- Homepage: https://playwright.dev
- Repository: https://github.com/microsoft/playwright
- Source: https://github.com/microsoft/playwright#readme
- Source: https://github.com/microsoft/playwright
- Source: https://github.com/microsoft/playwright/releases
- Source: https://playwright.dev
- Source: https://playwright.dev/agent-cli/introduction
- Source: https://playwright.dev/mcp/introduction
- Source: https://playwright.dev/docs/getting-started-vscode


## Playwright Test: check your site in real browsers

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.

### Where to use 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: Add an accessibility scan to key pages with the axe-core add-on, so missing labels fail the test run. (idea, not from the official pages)

### How to start
- Add it to a project and download the browsers it needs.

```
npm i -D @playwright/test
npx playwright install
```

- 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/);
});
```

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

```
npx playwright test
npx playwright show-report
```


### License
Free to use in paid and closed products under the Apache-2.0 license. If you hand on Playwright's own files, include the license. The browsers it downloads come with their own licenses.

### Good to know
- Each Playwright version needs its own browser builds, so download them again (playwright install) after every upgrade.
- The browsers take a few hundred megabytes of disk space and come from Microsoft's download servers.
- The docs ask for Node.js 22, 24 or 26 and macOS 14 or newer on a Mac.
- Each test gets a fresh browser profile, so cookies and logins do not leak from one test to the next.
- The project is very active; version 1.65.0 came out on 5 November 2026.

Checked 2026-11-11 against: https://github.com/microsoft/playwright/blob/main/README.md, https://github.com/microsoft/playwright/blob/main/LICENSE, https://playwright.dev/docs/intro, https://playwright.dev/docs/writing-tests, https://playwright.dev/docs/test-configuration, https://playwright.dev/docs/browsers, https://playwright.dev/docs/release-notes, https://registry.npmjs.org/@playwright/test, https://registry.npmjs.org/@playwright/test/1.65.0

### Mistakes to avoid
- Don't: await page.waitForTimeout(3000) before checking the page → Do: await expect(locator).toHaveText(...) and other web-first assertions (Assertions retry until the page is ready; fixed waits make tests slow and flaky.)
- Don't: npm i playwright @playwright/test  (both packages) → Do: npm i -D @playwright/test  only (npx playwright test stops working when both are installed.)
- Don't: Upgrading @playwright/test without downloading new browsers → Do: npm install -D @playwright/test@<version> && npx playwright install --with-deps (Every version needs its own browser builds; old ones do not match.)
- Don't: readonly submit = this.page.getByRole(...) as a class field in a page object (1.65+) → Do: 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.)
- Don't: page.accessibility.snapshot() for accessibility tests → Do: 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's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
