Playwright
84.9k stars
official open-source Has MCP Cross-platform Actively maintained
The browser automation framework. Run end-to-end tests, generate test scripts, and automate web interactions across Chromium, Firefox, and WebKit with JSON reporter output.
Playwright has both a CLI and an MCP server. See when to use each
Part of the Playwright CLI tools for AI agents
What your agent can do
Your CI pipeline runs tests but you don't know why they're failing. The test output says "expected element to be visible" with a cryptic selector. You try to reproduce locally, clicking through the app, can't find the issue. Your agent runs `npx playwright test --grep "checkout" --reporter=json --trace=on`, gets structured pass/fail results with trace files that contain screenshots at every step. The exact moment of failure, captured.Playwright's test runner outputs structured JSON. `--reporter=json` produces a complete test report with suite names, test names, pass/fail status, duration, error messages, and attachment paths. Your agent parses test results programmatically, identifies failures, reads error context, and can correlate failures with code changes. No log scraping.`npx playwright codegen` generates test scripts from browser interactions. Point it at a URL, click through the flow, and Playwright writes the test code. Your agent uses codegen output as a starting point, then refines the generated tests. It's a faster path to test coverage than writing tests from scratch.The official MCP server (microsoft/playwright-mcp, 29,600+ stars) gives AI agents direct browser access. Your agent navigates pages, fills forms, clicks buttons, takes screenshots, and runs accessibility audits through MCP. This is how agents interact with web UIs — not through HTTP requests, but through actual browser automation with DOM access.Playwright runs headless by default. No browser windows pop up. Tests execute in isolated browser contexts with automatic cleanup. Your agent runs full end-to-end test suites in CI without any display server, any browser configuration, or any human interaction. Three browser engines (Chromium, Firefox, WebKit) from a single API.
Limitations
Requires Node.js runtime (no standalone binary). Browser binaries are large (~400MB for all three engines). Test-focused by default — general-purpose web scraping is possible but not the primary use case. No built-in visual regression testing (use `toMatchSnapshot` for screenshot comparisons). Learning curve for Playwright's selector engine and auto-waiting behavior.
Key Commands
npx playwright test Run all test files with configurable reporter output
npx playwright test --grep Run only tests matching a pattern
npx playwright codegen Generate test scripts by recording browser interactions
npx playwright show-trace Open the trace viewer to analyze test execution with screenshots and DOM snapshots
npx playwright install Download browser binaries for Chromium, Firefox, and WebKit
GitHub Stats
repo microsoft/playwright
stars 84.9k
language TypeScript
license Apache-2.0
last commit Mar 25, 2026
FAQ
- Is Playwright free?
- Yes. Playwright is free and open-source under the Apache 2.0 license, maintained by Microsoft. Install with `npm install -D @playwright/test`. Browser binaries are downloaded separately with `npx playwright install`. No paid tiers, no usage limits.
- Can AI agents use Playwright?
- Yes, in two ways. First, the CLI: `npx playwright test --reporter=json` runs tests with structured output. Second, the official MCP server (microsoft/playwright-mcp, 29,600+ stars) gives agents direct browser control — navigate, click, fill forms, take screenshots, run accessibility audits. This is the primary way AI coding agents interact with web UIs.
- What is the Playwright MCP server?
- microsoft/playwright-mcp (29,600+ stars) is the official MCP server that gives AI agents browser automation capabilities. Your agent navigates pages, interacts with elements, takes screenshots, and runs audits through the Model Context Protocol. It's how agents like Claude Code verify web application behavior without manual browser testing.
- How does Playwright compare to Cypress?
- Playwright supports all three browser engines (Chromium, Firefox, WebKit). Cypress supports Chromium-based browsers only. Playwright runs tests in parallel by default. Playwright has official MCP integration for AI agents. Cypress has a friendlier GUI test runner for human developers. For agent-driven testing workflows, Playwright's multi-browser support and MCP server make it the stronger choice.
- Can Playwright test mobile viewports?
- Yes. Playwright emulates mobile devices including viewport size, user agent, touch events, and geolocation. `npx playwright codegen --device='iPhone 14'` records interactions in a mobile viewport. Your agent tests responsive designs across desktop and mobile from the same test suite.
Last verified: Mar 25, 2026