World’s largest virtual agentic engineering & quality conference
Playwright AI explained: the Planner, Generator, and Healer agents built into Playwright, the MCP server, and how AI generates and self-heals your tests.

Paulo Oliveira
Author
Srinivasan Sekar
Reviewer
Published on: November 23, 2025
Last Updated on: August 17, 2026
Playwright now ships its own AI agents, so "using AI with Playwright" no longer means pasting prompts into a chatbot and cleaning up the output.
This guide covers the three layers that matter: the Planner, Generator, and Healer agents built into Playwright, the Playwright MCP server that gives an agent a real browser, and the external agents that author Playwright tests from plain language.
TL;DR
Playwright AI is the set of AI capabilities that plan, write, and repair Playwright tests. It spans three layers: the Planner, Generator, and Healer agents that ship with Playwright, the Playwright MCP server that gives an AI agent a real browser to drive, and external agents that author Playwright tests from plain language.
What Are the Playwright AI Layers?
How Do You Set Up Playwright Agents?
Run npx playwright init-agents with the loop flag matching your editor. Supported editors: VS Code, Claude Code, Codex, and OpenCode. For coverage beyond one machine, TestMu AI runs the resulting suites in parallel across 3,000+ browser and OS combinations.
AI addresses the two costs that sink most Playwright automation suites: the hours spent authoring tests, and the larger ongoing bill for repairing them every time the UI shifts. The five capabilities below map to those costs.
You can also point an agent at Playwright Skills, a set of markdown guides that give coding agents the framework conventions to generate against.
They solve different halves of the problem and are not alternatives. Playwright is a deterministic browser automation library: it clicks, types, and asserts, and it does the same thing on every run. The OpenAI API is a reasoning layer: it decides what to do or interprets what happened, and its output varies between runs. Playwright cannot decide anything, and the OpenAI API cannot touch a browser.
The question comes up because AI agent demos blur the line. An agent that "browses the web" is almost always an LLM deciding the next action and a browser automation library carrying it out. Playwright MCP, covered below, is exactly that pairing with a defined protocol between the two halves.
| Consideration | Playwright | OpenAI API |
|---|---|---|
| What it does | Drives a real browser: navigation, input, waiting, assertions. | Generates and interprets text, including deciding what step to take next. |
| Determinism | The same script produces the same actions every run. | The same prompt can produce different output between runs. |
| Cost per run | Compute only. No per-action charge. | Billed per token, so a long run costs more than a short one. |
| Speed | Milliseconds per action. | A model call per decision, which dominates total runtime. |
| Fails when | The locator no longer matches the page. | The page is ambiguous, or the model reasons its way to the wrong action. |
| Right job | Regression suites and any check that must give the same verdict every time. | Authoring tests, triaging a failure, or handling a flow too variable to script. |
The practical rule follows from the determinism row. A regression suite exists to give the same answer every time, so putting a non-deterministic model in the execution path defeats its purpose. Use the model where variation is acceptable or useful, which is authoring and diagnosis, and keep Playwright in the path that has to be repeatable.
That is why the pairing is more common than the choice. The model writes or repairs the Playwright script; the Playwright script is what runs in CI. Playwright's own Generator and Healer agents, covered next, are built on exactly this division of labour.
Playwright ships three agents of its own. Per the Playwright test agents documentation, the Planner explores the app and produces a Markdown test plan, the Generator turns that plan into Playwright Test files, and the Healer runs the suite and repairs failing tests.
The split matters because each stage produces a reviewable artifact. A human approves the Markdown plan before any code exists, which is a cheaper place to catch a wrong assumption than a generated spec file.
Install them with a single command, passing the loop flag for your editor. Playwright supports VS Code, Claude Code, Codex, and OpenCode.
npx playwright init-agents --loop=vscode
npx playwright init-agents --loop=claude
npx playwright init-agents --loop=codex
npx playwright init-agents --loop=opencodeThe VS Code path needs version 1.105 or later for the agentic experience to work. For the full walkthrough, including an end-to-end run from a Jira ticket to committed tests, see the guide to AI and Playwright MCP, or the deeper treatment of Playwright Agents.
One limitation worth planning around: the Healer repairs tests against the browsers on your machine. A locator that heals correctly in local Chromium can still fail on Safari or an older Edge build, so the healed suite needs a run across real browser and OS combinations before you trust the repair.
Playwright MCP is an open-source Microsoft server that exposes browser automation as tools any Model Context Protocol client can call, so an AI assistant can open pages, click, type, and read results through Playwright.
Its design decision is the important part. The Playwright MCP repository, at 35.9k stars and 3k forks, states that the server uses Playwright's accessibility tree rather than pixel-based input and operates purely on structured data.
That means no vision model in the loop. The agent reads a semantic description of the page instead of guessing at a screenshot, which is why MCP-driven runs are cheaper and more repeatable than screenshot-based browser agents.
TestMu AI runs an Automation MCP Server on the same protocol, connecting AI assistants to test sessions on the grid so an agent can pull execution data, analyze failures, and triage them without a human re-running the build. Start with the Automation MCP Server documentation, or compare hosted options in the MCP servers overview.
For worked examples, the guide to vibe testing with Playwright MCP covers running UX scenarios in natural language and turning them into reusable scripts. Teams on other stacks can apply the same pattern via vibe testing with Selenium. To build an agent loop yourself instead of using a pre-built server, Playwright LangChain covers wrapping Playwright actions as tools, plus the SSRF and recursion limits production agents need.
Playwright's own agents handle plan, generate, and heal inside the repository. External agents cover the cases they do not: authoring from a Jira ticket or PRD, running the result across browsers you do not own, and letting a non-coder contribute coverage.
Natural Language Processing sits at the core of that authoring step. AI agents support NLP testing, interpreting prompts and converting them into working Playwright scripts.
Three tools cover most of this ground: KaneAI, ChatGPT, and Claude. The first is purpose-built for testing; the other two are general assistants pressed into the job.
KaneAI is a GenAI-native test agent that plans, authors, and evolves tests for web and mobile from natural language. The difference from a chatbot is that it resolves elements against the live application by intent rather than emitting a selector string it cannot verify.
Features:
Example:
The screenshot below shows the KaneAI Web Agent interpreting user actions as test steps. Structured steps build on the left while the browser on the right shows the state each one produced.
Saving the test generates the corresponding scripts, which you can export into your framework and language of choice and commit alongside hand-written specs.
To get started, refer to this guide on KaneAI.
KaneAI authors the test. The gap it leaves, and the one every AI coding agent leaves, is verification: an agent reads and writes source code, and its checks (unit tests, type checkers, linters) all operate on that same closed surface. None of them render the page, so an agent can report "passed" on a button wired to the wrong endpoint.
Kane CLI closes that loop from the terminal. It drives real Chrome through the DevTools Protocol against a natural-language objective, and it is constrained to actions a real user could take, so it will not inject JavaScript to force a pass that a user could never reach.
Its agent mode emits NDJSON, one typed event per line, ending in a run_end object carrying status, duration, extracted values, and a link to the run. That is what makes it callable by Claude Code, Codex CLI, or Cursor as a verification step rather than something a human reads.
kane-cli run "log in, add the first product to the cart, assert the cart total updates" \
--url https://ecommerce-playground.lambdatest.io/ \
--agent --headless --timeout 300Two details matter for a Playwright team specifically. Any completed run exports to native Playwright code, so the flow you described in English becomes a spec file you own. And its autoheal scores every element match, rejecting low-confidence ones up front rather than clicking the wrong element and passing quietly, which is the failure mode that makes self-healing hard to trust.
In CI it returns standard POSIX exit codes, 0 for pass, 1 for a failed assertion, 2 for an environment error, and 3 for a timeout, so no wrapper script is needed to gate a merge.
Note: Kane CLI returns POSIX exit codes for CI and exports any completed run to native Playwright code, so it can gate a merge and still leave you a spec file you own. Read the Kane CLI docs
ChatGPT, developed by OpenAI, generates detailed Playwright scripts from a prompt despite never having been built for testing.
Its value is speed of drafting: a rough end-to-end test, an automation flow to experiment with, or a manual test case translated into code. The output still needs review before it enters a suite.
Because it neither executes code nor touches a live browser, it can invent unstable selectors or reach for deprecated Playwright methods. Run the script, validate every selector, and refine against the current UI before committing.
Example:
Prompt: Write a Playwright test in JavaScript to test user login and validate the success toast notification.
ChatGPT returns a complete script with page navigation, data entry, click actions, and toast visibility assertion, often with helpful comments.
Claude, built by Anthropic, understands natural language and writes code in many languages. It is not a dedicated testing tool, though it handles test automation well.
Ask it to write Playwright scripts, outline end-to-end flows, or convert manual test steps into runnable code. It suits prototyping a test quickly or describing an idea in plain English and getting usable code back.
The same caveat applies as with ChatGPT: no code runs and no browser is touched, so unstable selectors and outdated methods reach you unflagged. Run the script and check the selectors before adding it to a suite. Pairing Claude with Playwright MCP removes most of this gap, since the agent can then verify its own output against a live page.
Example:
Prompt: Write a test in TypeScript using Playwright that tests a multi-step checkout process, with data entry, payment mock, and confirmation.
Claude generates a multi-part script with a logical structure and clear separation of steps.
Playwright Codegen uses no AI at all, which is worth stating plainly in a guide about AI. It records interactions and translates them into executable Playwright scripts, deterministically.
That determinism is a feature. Codegen never invents a method that does not exist, which is the most common failure of prompt-generated tests. It also does not handle complex logic, loops, or conditional flows.
To use Codegen, run the following command:
npx playwright codegenCodegen opens a browser alongside the interactive Playwright Inspector. As you move through the application, it logs your actions and converts them into test scripts.
Recorded output carries auto-generated selectors and simple visibility assertions. Complex validations are yours to add, and because it records actions exactly as they happened, the selectors it picks are often more specific than they need to be.
Agents generate tests faster than teams can organize them, which turns a suite of a few hundred AI-authored specs into its own problem. TestMu AI's test management platform centralizes cases, tracks execution, and identifies semantically similar tests so an agent does not create a fourth version of the same login check.
Features:
To begin with, head over to this Test Manager support doc guide.
The wider ecosystem of AI testing tools around Playwright churns faster than most guides admit, so check that a project is still maintained before you build on it.
Auto Playwright
Auto Playwright adds an auto() function that takes a plain-text description of a step and resolves it at runtime, so no selector is written by hand. The open-source repository carries 844 stars and integrates directly into an existing Playwright project.
Treat it as experimental rather than production tooling. Its own README steers production users to ZeroStep, and complex logic still needs manual implementation.
ZeroStep (discontinued)
ZeroStep generated Playwright tests from natural-language instructions and is still recommended by many guides published this year. It is no longer available: as of August 2026 the zerostep.com domain returns no DNS record at either the apex or the www host, so the hosted service cannot be reached.
If you inherited a suite built on it, the natural-language authoring layer is the piece to replace. Options are covered in this guide to ZeroStep alternatives.
Note: Playwright Agents heal tests against the browsers on your laptop. TestMu AI reruns the healed suite across 3,000+ browser and OS combinations, so a repair that only works in local Chromium is caught before it ships. Try TestMu AI Now!
Developer sentiment has not caught up with the marketing. In the Stack Overflow Developer Survey 2025, more developers actively distrust the accuracy of AI tools (46%) than trust it (33%), and only 27.5% currently use AI even partially for testing.
That skepticism is earned. The limits below are the reasons behind it.
In the video below, Andrew Knight, Senior Director of Product Management at Cycle Labs, works through advanced Playwright techniques and how AI fits into writing scalable tests.
Start with the agents you already have. Run npx playwright init-agents with the loop flag for your editor, point the Planner at one real flow in your application, and read the Markdown plan it produces before letting the Generator write a single spec file.
That first plan tells you most of what you need to know. If it captures the flow accurately, the Generator and Healer are worth wiring into your workflow. If it misreads the app, no amount of prompt tuning downstream will fix it.
Add MCP once you want the agent to verify its own output against a live page, and add an external agent such as KaneAI when authoring needs to start from a Jira ticket or include people who do not write code.
Whichever layer you adopt, run the result somewhere broader than one laptop before trusting it. TestMu AI executes Playwright suites in parallel across 3,000+ browser and OS combinations, which is where a locally healed selector proves whether it actually holds. The Playwright testing documentation covers the grid setup.
For a CLI-first take on the same idea, see how an autonomous agent stacks up in Kane CLI vs Playwright.
Author
Paulo is a Quality Assurance Engineer with more than 15 years of experience in Software Testing. He loves to automate tests for all kind of applications (both backend and frontend) in order to improve the team’s workflow, product quality, and customer satisfaction. Even though his main roles were hands-on testing applications, he also worked as QA Lead, planning and coordinating activities, as well as coaching and contributing to team member’s development. Sharing knowledge and mentoring people to achieve their goals make his eyes shine.
Reviewer
Srinivasan Sekar is Director of Engineering at TestMu AI (formerly LambdaTest), where he leads engineering and open-source initiatives behind the Selenium and Appium automation grid and owns TestMu AI's MCP Server. A committer to Appium and a contributor to Selenium, WebdriverIO, Taiko, and AppiumTestDistribution, he brings over 15 years of experience in quality engineering and open-source technologies. He is the author of the Apress book 'The MCP Standard: A Developer's Guide to Building Universal AI Tools with the Model Context Protocol,' a Certified Kubernetes and Cloud Native Associate, and an international conference speaker. Before TestMu AI he spent over eight years at Thoughtworks as a Principal Consultant and Quality Architect. Srinivasan holds a B.Tech in Information Technology from Anna University.
Did you find this page helpful?
More Related Blogs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance