Playwright for AI browser agents: how Browser Use, Skyvern, Browser Operator and Steel automate the web in 2026
What Playwright is
Playwright was released by Microsoft in 2020, created by engineers who had previously built Puppeteer at Google. It drives Chromium, Firefox and WebKit through a single API, available for TypeScript and JavaScript, Python, Java and .NET. Its test runner, Playwright Test, is one of the most used end-to-end testing tools for web apps.
Features that matter for AI agents:
| Feature | Why agents need it |
|---|---|
| Auto-waiting | Actions wait until elements are visible and enabled, reducing flaky steps |
| Accessibility snapshots | A text tree of roles and names that a model can read cheaply |
| Locators by role, text and label | Agents can target "the Sign in button" instead of fragile CSS selectors |
| Browser contexts | Isolated sessions with separate cookies, for running many agents at once |
| Network interception | Block ads and trackers, capture API responses, mock services |
| Tracing and video | Replay what an agent did when debugging |
| Persistent profiles | Keep logins between runs |
Which directory projects use it
| Project | What it does | Relationship to Playwright |
|---|---|---|
| Browser Use | Python library that lets any model control a browser to complete tasks | Built on Playwright originally; now talks to Chrome DevTools Protocol directly with a Playwright-compatible approach |
| Skyvern | Automates forms and workflows on websites using vision and language models | Uses Playwright to run browsers |
| Browser Operator | Open-source browser with a built-in AI agent | Built on Chromium and its automation interfaces |
| Steel | Open-source browser API for agents, with sessions, proxies and CAPTCHA handling | Exposes browsers that Playwright, Puppeteer or Selenium connect to |
Commercial tools such as OpenAI's and Anthropic's computer-use agents also run inside managed browsers, but the open-source projects above let you run the whole loop yourself.
Playwright 1.64
Playwright 1.64.1, the current patch release, shipped on October 14, 2026. New in the 1.64 line:
| Addition | What it does |
|---|---|
| WebMCP (experimental) | page.webmcp and frame.webmcp APIs to work with tools that pages expose to agents |
| VP9 video | Recording with a custom frame rate |
| Shuffled tests | Run tests in random order to expose hidden dependencies |
| Project defaults and group-level locks | More control over test configuration and shared resources |
locator.within() | Scope a search inside another element |
page.getByRef() | Target elements by references from snapshots |
Version 1.64.1 fixed a regression where packaged Electron apps failed to report their first window, and a regression with cross-origin redirects on Chromium 155 and later. If you automate Electron apps or follow redirects across domains, update to 1.64.1.
Why WebMCP matters
Today, agents operate websites the way people do: read the screen, find a button, click it, and hope the layout has not changed. WebMCP proposes that sites declare tools in the page, such as searchFlights with typed parameters, so an agent can call them directly. Playwright's experimental support means teams can start testing those tools in their own sites before browsers ship full support. If the standard spreads, browser agents will become faster and far less error-prone on cooperating sites.
How a browser agent works
A typical loop in Browser Use or Skyvern:
- Open a page with Playwright.
- Capture the state: an accessibility snapshot or simplified DOM, often with a screenshot that marks interactive elements with numbers.
- Send the task, the state and the history of previous steps to a model.
- The model replies with an action, such as click element 14 or type an email into element 7.
- Execute the action with Playwright, wait for the page to settle, and repeat until the task is done or a step limit is reached.
Text snapshots are cheaper and faster than screenshots; vision helps with canvas-heavy pages, maps and visual CAPTCHAs. Many agents combine both.
Playwright MCP for coding agents
Microsoft's Playwright MCP server connects a browser to any MCP client, including Claude Code, Cursor, VS Code and Windsurf. The agent gets tools to open URLs, click, type, take a snapshot and take a screenshot. Developers use it to let a coding agent open the app it is building, try the feature, read console errors and fix them. It is also handy for writing Playwright tests: the agent explores the page and then writes a test file with stable locators. See the MCP stack page for how MCP servers work.
Running browsers at scale
| Option | Notes |
|---|---|
| Local headless browsers | Fine for development and small jobs; one Chromium uses a few hundred MB of RAM |
| Docker containers | Official Playwright images include browsers and dependencies; see the Docker stack page |
| Steel (self-hosted) | Open-source browser API with session management, proxies and a live viewer |
| Hosted browser services | Steel Cloud, Browserbase, Hyperbrowser and others; billed per browser hour |
| Kubernetes | Pools of browser containers for high volume; see the Kubernetes stack page |
Browsers are heavy. Plan memory for every concurrent session, close contexts when done, and restart long-lived browsers periodically to avoid memory growth.
Cost and reliability
The model calls usually cost more than the browsers. A 20-step task that sends a screenshot and history each step can use a large number of input tokens. Ways to reduce cost and errors:
- Prefer accessibility snapshots to screenshots when the page allows it.
- Trim history to the last few steps plus a running summary.
- Write deterministic Playwright code for steps that never change, such as logging in, and let the model handle only the variable parts.
- Cache successful action sequences and replay them, falling back to the model only when the page changes; Skyvern and Browser Use both support forms of this.
- Set a step limit and a timeout for every task.
Common failure modes
| Problem | Fix |
|---|---|
| Agent clicks before content loads | Wait for network idle or a specific element before capturing state |
| Pop-ups and cookie banners block actions | Dismiss them with fixed code or block their scripts |
| Infinite loops on the same step | Detect repeated actions and stop or replan |
| Login walls and two-factor prompts | Use saved profiles or hand off to a human |
| Sites detect automation | Use a hosted browser with proper fingerprints, or ask the site for API access |
Security
Browser agents read untrusted content, so prompt injection is a real threat: a page can contain hidden text telling the agent to visit another site or reveal data. Limit what the agent can do:
- Run browsers in isolated containers without access to internal networks.
- Restrict the domains an agent may visit for a given task.
- Do not give agents saved passwords or payment details for sites outside the task.
- Require human approval for purchases, form submissions with personal data and account changes.
- Log every action with Playwright tracing so you can audit what happened.
Testing AI features with Playwright
Playwright is also the usual tool for testing AI products themselves. End-to-end tests can open a chat interface, send a prompt, and check that a streamed answer appears, that citations render and that error states work. Because model output varies, assert on structure rather than exact text: a response appears within a time limit, it contains a link, the feedback buttons work. For deterministic tests, point the app at a mock model server that returns fixed replies, and keep a smaller set of tests against the real model that check broad behavior.
Choosing a starting point
| Goal | Start with |
|---|---|
| Let a coding assistant use a browser | Playwright MCP |
| Build a Python agent that completes web tasks | Browser Use |
| Automate forms across many similar sites | Skyvern |
| Host many browser sessions for your agents | Steel |
| A browser with an agent built in | Browser Operator |
| Deterministic scraping or testing | Plain Playwright |
Related: MCP stack, Python stack, TypeScript stack, Docker stack, Electron stack, Stack index.
Frequently asked questions
Why do AI agents use Playwright?
It controls real browsers reliably across Chromium, Firefox and WebKit, waits for elements automatically, handles multiple tabs, frames and downloads, and exposes the accessibility tree, which gives agents a compact text view of a page. It has official libraries for Python, TypeScript, Java and .NET, so it fits most agent frameworks.
What is WebMCP in Playwright 1.64?
WebMCP is a proposed web standard that lets a website declare tools, such as search products or add to cart, that an AI agent can call directly instead of clicking through the interface. Playwright 1.64 added experimental page.webmcp and frame.webmcp APIs to list and call those tools from scripts and tests. Few sites expose WebMCP tools yet.
What is Playwright MCP?
An official Microsoft MCP server that lets AI assistants drive a browser through Playwright. The assistant receives accessibility snapshots of the page and calls tools to click, type, open pages and take screenshots. Developers use it to let coding agents test web apps they are building.
Is Playwright better than Selenium or Puppeteer for agents?
For most new agent projects, yes. Puppeteer focuses on Chromium and JavaScript; Selenium supports many languages but has a slower, more verbose API. Playwright combines broad browser support, multiple languages, auto-waiting and good tooling. Some agent libraries now talk to Chrome DevTools Protocol directly for speed, while keeping a Playwright-style approach.
How do browser agents avoid being blocked?
Hosted browser services such as Steel, Browserbase and others provide residential proxies, managed fingerprints and CAPTCHA handling. Respect each site's terms of service and robots rules; many sites forbid automated access, and evading bot protection can breach contracts or laws.