Playwright Core
Headless browser automation library for cross-browser testing and web scraping.
3. Used by agents' projects
Dependency in 80 public GitHub projects set up for AI coding agents that we scanned (1.3%).
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. Tap a verdict to see its source.How we checkedReport an error
What Playwright Core does
One browser engine for Chromium, Firefox and WebKit with several entry points: a test runner, a scripting library, and two agent interfaces (a CLI and an MCP server) where agents act on refs from accessibility snapshots instead of on screenshots.
Playwright Core popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How Playwright Core is used
- Playwright Core is a dependency in 80 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (1.6% of the 4,867 JavaScript/TypeScript ones), #3 of 141 in scraping, browsers and parsing.
- 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 335; those are left out of every share on this page.
- The most used alternative in our scan is Puppeteer (86 projects).
- Projects that use it most often also use Vitest (73.8%), tsx (60.0%), Zod (72.5%).
- It is more common in projects set up for OpenClaw (9.6%) than for Cursor (0.4%).
By coding agent
Often used with
Playwright Core in practice
Strengths
The MCP server gives the model an accessibility tree in which each element has a ref. The next tool call then targets that ref. The docs say this needs no vision model and no coordinate guessing.
Playwright CLI is aimed at Claude Code, Copilot and similar agents. The maintainers write that it is "more token-efficient than MCP" because commands do not load large tool schemas or accessibility trees into the model context.
Actions wait until elements are actionable, and assertions retry until their conditions are met. The docs present this as the replacement for hand-written timeouts.
The <code>playwright</code> library covers plain automation scripts. The README shows examples for screenshots, A4 PDFs, iPhone emulation and blocking image requests with <code>page.route</code>.
Watch out for
The README tells you to install <code>playwright</code>, <code>@playwright/test</code>, <code>@playwright/cli</code> or <code>@playwright/mcp</code>. None of these pages explains what <code>playwright-core</code> contains by itself or when to choose it.
The docs' own comparison table rates the MCP server higher on token cost, because tool schemas and snapshots sit in the model context. The CLI is rated lower.
The MCP server starts headed. The CLI defaults to headless. Expect a browser window to appear unless you change the setting.
Take a screenshot with the library
import { chromium } from 'playwright';
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://playwright.dev/');
await page.screenshot({ path: 'screenshot.png' });
await browser.close();More about Playwright Core
Agent Skills for it
- playwright-core: Battle-tested Playwright patterns for E2E, API, component, visual, accessibility, and security testing. Covers locators, assertions, fixture
Head to head
- Puppeteer vs Playwright Core used together in 0 projects
Packages around it
- vitest: test runner
- tsx: TypeScript runner
- dotenv: env file loader
- zod: schema validation
- undici: HTTP client
- ws: WebSocket library
More in Scraping, browsers and parsing
Alternatives
Playwright Core This page
Headless Chrome/Chromium automation for scraping, testing and screenshot generation.
Headless Chrome/Chromium control library for automation and testing.
Get started
Install it.
npm install playwright-coreRules for your agent
## Playwright
- Locate elements with `getByRole`, `getByLabel`, `getByPlaceholder` or `getByTestId`, not brittle CSS paths.
- Do not add manual sleeps or timeouts. Rely on auto-wait and web-first assertions such as `expect(page).toHaveTitle(...)`.
- 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`.
- In a large codebase, drive the browser with `playwright-cli` rather than MCP. It has lower token cost and is headless by default.
- When using the CLI or MCP, act on element refs (e.g. `e21`) from the latest snapshot, not on screen coordinates.
- In library scripts, always call `await browser.close()` when done.