Slack Slack
@microsoft
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
概览
What is Playwright?
Playwright is a framework for web automation and testing that drives Chromium, Firefox, and WebKit with a single API. It is designed for end-to-end tests, browser automation scripts, and as a tool for AI agents. The Playwright MCP server specifically gives AI agents full browser control through the Model Context Protocol (MCP), using structured accessibility snapshots instead of vision models or screenshots.
How to use Playwright?
To use Playwright as an MCP server for AI agents, add it to your MCP client (VS Code, Cursor, Claude Desktop, Windsurf, etc.) with the command npx @playwright/mcp@latest. For Claude Code, run claude mcp add playwright npx @playwright/mcp@latest. The agent then interacts with pages via tools that navigate, fill forms, take screenshots, mock networks, and manage storage – all using element references from the accessibility tree.
Key features of Playwright
- Cross-browser automation (Chromium, Firefox, WebKit) on Linux, macOS, Windows
- Structured accessibility snapshots for AI agents without vision models
- Auto-wait and web-first assertions with no artificial timeouts
- Resilient locators based on role, label, placeholder, or test ID
- Test isolation with fresh browser contexts per test
- Tracing, screenshots, and video capture on test failures
Use cases of Playwright
- End-to-end testing across browsers with Playwright Test
- AI agent web automation via the MCP server
- Web scraping, PDF generation, and screenshot capture using the Playwright Library
- Test authoring and debugging within VS Code using the extension
- Cross-browser validation in continuous integration pipelines
FAQ from Playwright
What browsers does Playwright support?
Playwright supports Chromium, Firefox, and WebKit on Linux, macOS, and Windows, with both headless and headed execution.
How does Playwright MCP allow AI agents to interact with pages without vision?
It uses structured accessibility snapshots that present the page as a tree of elements with references (e.g., ref=e5). Agents use these refs to click, type, and interact deterministically, without visual ambiguity.
Can Playwright be used for end-to-end testing?
Yes, Playwright Test is a full-featured test runner built for end-to-end testing, providing auto-waiting, web-first assertions, parallel execution, and full browser isolation.
Does Playwright have a VS Code extension?
Yes, the Playwright VS Code extension adds test running, debugging, code generation (CodeGen), locator picker, and trace viewer integration directly into the editor.
Is Playwright available in other programming languages?
Yes, Playwright is also available for Python, .NET, and Java.

