Favicon of playwright

playwright

A browser automation and testing framework that drives Chromium, Firefox, and WebKit through one API, with a test runner, CLI, MCP server, and library.

Playwright is a framework for automating and testing web pages across Chromium, Firefox, and WebKit using a single API. It ships as several tools built around that same underlying automation engine: a full end-to-end test runner, a command-line tool built for coding agents, an MCP server for LLM-driven browser control, a library for writing custom automation scripts, and a VS Code extension for authoring and debugging tests. It's built for developers who need reliable, cross-browser testing or scripting, and increasingly for AI coding agents that need to drive a real browser.

Key features

  • Playwright Test: a full end-to-end test runner with automatic browser isolation, auto-waiting, and web-first assertions that retry until conditions are met instead of relying on fixed timeouts.
  • Resilient locators: finds elements the way users see them, with methods like getByRole, getByLabel, getByPlaceholder, and getByTestId.
  • Test isolation and saved auth state: each test runs in its own fresh browser context, and you can save authentication state once and reuse it across tests instead of logging in repeatedly.
  • Tracing and Trace Viewer: captures execution traces, screenshots, and video on failure, including DOM snapshots, network requests, and console messages, viewable with npx playwright show-trace.
  • Playwright CLI: a command-line interface built specifically for coding agents (Claude Code, Copilot, and similar), more token-efficient than MCP because it avoids loading large tool schemas and accessibility trees into the model's context.
  • Playwright MCP: an MCP server that gives AI agents full browser control through structured accessibility snapshots rather than screenshots or vision models, usable from VS Code, Cursor, Claude Desktop, Windsurf, and other MCP clients.
  • Playwright Library: use Playwright directly as a library for scripting: screenshots, PDF generation, mobile device emulation, and network request interception, without a test runner.
  • Cross-platform, cross-browser: headless and headed execution on Linux, macOS, and Windows, across Chromium, Firefox, and WebKit, plus bindings for Python, .NET, and Java besides the native Node.js/TypeScript API.

Ideal use cases

Playwright fits teams that need dependable end-to-end tests across multiple real browser engines, especially where flaky, timeout-based tests have been a problem elsewhere, since its auto-waiting and web-first assertions are designed specifically to reduce that flakiness. It also fits developers writing browser automation scripts outside of testing (scraping, PDF generation, screenshot pipelines) via the Library, and teams building or using AI coding agents that need to drive a browser through either the CLI or the MCP server.

It's a heavier tool than needed if you only ever test in one browser engine and don't care about cross-browser coverage, where a lighter, single-engine tool might be simpler to set up. It's also primarily aimed at browser-level testing; it's not a unit testing framework, so you'd still pair it with something like Jest or Vitest for logic-level tests that don't need a real browser. Teams outside the JavaScript/TypeScript ecosystem are still covered, since Playwright is also officially available for Python, .NET, and Java, so a mixed-language organization doesn't need a separate tool per stack.

Installation

For end-to-end testing with Playwright Test:

npm init playwright@latest

Or add it manually:

npm i -D @playwright/test
npx playwright install

Run tests with:

npx playwright test

For the CLI aimed at coding agents:

npm install -g @playwright/cli@latest

For the MCP server, add this to your MCP client configuration:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["@playwright/mcp@latest"]
    }
  }
}

Or, for Claude Code specifically:

claude mcp add playwright npx @playwright/mcp@latest

To use Playwright as a plain automation library:

npm i playwright

The VS Code extension is installed separately from the Marketplace and adds test running, debugging, and code generation, recording your interactions into test code, directly in the editor. Optional skills can be added to the CLI for richer agent integration with playwright-cli install --skills, and playwright-cli show opens a dashboard with live screencast previews of running browser sessions that you can click into and take remote control of.

Categories:

Frequently asked questions

Share:

Stars
92.5K
Forks
6.1K
Last commit
3 hours ago
Repository age
7 years
License
Apache-2.0
Self-hosted
No
Activity score
88/100
View Repository
Built with:

Similar to playwright

Favicon

 

  
  
Favicon

 

  
  
Favicon