Apr 23, 2026
From Manual Testing to AI-Assisted Automation with Playwright Agents
This blog discusses the value of Playwright Agents in automating workflows. It provides a detailed description of setting up the system, as well as a breakdown of the Playwright Agent’s automation process.
Author


Book a call
Table of Contents
For years, automation engineers have followed a familiar rhythm. Requirements come in, test cases are written, scripts are automated, locators break, scripts fail, and debugging begins. Fix, re-run, repeat.
This cycle hasn’t changed much, even though frameworks have evolved from Selenium to Cypress to modern tools like Playwright.
What if your automation framework didn’t just execute tests — what if it planned them, wrote them, ran them, and even fixed them when they broke? That’s exactly what Playwright Test Agents bring to the table.
Playwright introduced these AI-powered agents in version 1.56 to automate key parts of the testing lifecycle — planning, generating, and healing tests — using an agentic loop that interacts with your live application.
The Evolution of Automation with Playwright
Playwright became popular by addressing common automation challenges like flaky tests and synchronization issues. With features like automatic waiting, semantic locators such as getByRole, and built-in tracing, it reduced the effort required to stabilize tests. This allowed QA engineers to focus more on test coverage rather than debugging framework issues. However, even with these improvements, designing and maintaining test scripts still remained a manual effort.
We still had to:
- Translate requirements into scenarios
- Convert scenarios into code
- Refactor when UI changes
- Fix broken locators
Introducing Playwright Test Agents
Playwright Test Agents are AI-assisted automation workflows embedded directly into your Playwright project, designed to help you:
- Explore an application and produce a test plan
- Transform that plan into executable Playwright test code
- Run tests and automatically repair failures
There are three core agents:
The Planner Agent takes natural language input and converts it into structured test scenarios. It uses the seed test as context to explore the application, understand user flows, and identify possible edge cases. The output is a detailed test plan with steps and expected outcomes, similar to how a QA engineer would design test cases.
The Generator Agent takes these structured scenarios and converts them into executable Playwright scripts. While generating code, it interacts with the live application to validate selectors, identify stable locators, and ensure assertions reflect actual UI behavior. It can also follow architectural patterns like Page Object Model, producing manageable and scalable test code.
The Healer Agent focuses on maintaining test stability. When a test fails, it replays the scenario, inspects the DOM, and identifies what caused the failure. It then attempts to fix the issue by updating selectors, adjusting waits, or modifying interaction logic, reducing the manual effort required for test maintenance.
These agents can be invoked independently or chained together in a complete “agentic loop”:
Planner → Generator → Healer
Project Setup — Step by Step (Beginner Friendly)
If you already know basic Playwright automation, this should feel like an extension of that knowledge. If not, stick with it. By the end, you will understand how these agents help even if you’re new to automation.
1. Create a Playwright Project
Now install Playwright:
You now have a basic Playwright project.
2. Initialize Playwright Agents

This command generates agent files in your project — which you’ll recognize in the screenshot below:

A folder named .github/agents contains:
- playwright-test-planner.agent.md
- playwright-test-generator.agent.md
- playwright-test-healer.agent.md
These are the agent definitions that your AI tool (like Claude Code, VS Code Copilot, or OpenCode) uses to understand how to plan, generate, and heal tests.
Under the root folder, you also see:
- specs/ – for Markdown plans
- tests/ – for generated Playwright test files
- seed.spec.ts – a seed test that bootstraps the environment
This exact file structure is aligned with Playwright’s agent conventions: .github/agents, specs/, and tests/
A seed test is essential because it provides a starting context that the planner uses to understand where to begin exploration, including any setup required (like logging in or navigating to a landing page).

Next, add dummy seed data to a JSON file (optional but recommended):

The seed test and seed data help the Planner understand context and scenarios, which makes its output far more relevant and accurate.
How the Planner Agent Works
The Planner Agent is like a QA analyst powered by AI. Rather than immediately writing code, it first produces a structured Markdown test plan that describes required test scenarios, user flows, steps, expected outcomes, and test data.

For example, provide a prompt like:
“Create a test plan for login functionality with valid and invalid user scenarios using the seed test context.”
The Planner will explore your live application (through the seed test) and generate a Markdown file under specs/ such as:
specs/login-plan.md
This file contains detailed, human-readable test plans, not code, but instructions for how you want the generator to build tests.

You can review this file before moving to code generation.
Generator Agent: Turning Plans into Code
Once you have a test plan, it’s time to generate actual automation scripts.

The Generator reads the Markdown plan, actively interacts with the browser to verify selectors and assertions, and produces test scripts under the tests/ directory. Similar to this:

Each test should mirror a scenario from the plan.
Because the Generator interacts directly with the live app and evaluates selectors as it writes code, the tests it generates are often more stable and accurate than typical prompt-only AI output.
Healer Agent: Using AI to Fix Failing Tests
Inevitably, tests fail. It might be due to UI changes, such as an updated locator or changed button label.
Traditionally, you would open your editor, inspect the DOM, update selectors, and re-run tests. With Playwright’s Healer Agent, this can be assisted by AI.
Invoke the healer with a prompt like:
“Run and fix the failing test tests/amazon-search-add-to-cart-edge.spec.spec.ts.”
The healer will:
- Replay the failing test in debug mode
- Inspect the DOM to find equivalent elements or flows
- Propose updates to locators or waits
- Re-run until the test passes, or decide that the test really reflects a broken feature.
This reduces repeated manual debugging cycles, especially for tests that only break due to minor UI refactors.
From Prompt to Execution: Inside the Agent Workflow
While using Playwright Test Agents feels simple from a user perspective, there is significant processing happening in the background.
The agents operate through an agentic loop where they can read project files, execute tests, interact with the browser, and inspect the live DOM. For example, the Planner uses the seed test to explore the application and understand flows, the Generator validates selectors in real time while generating scripts, and the Healer replays failing tests to identify and fix issues.
Structuring Tests with Page Object Model
One of the biggest benefits of designer prompts is instructing the generator to produce maintainable code, and that starts with architecture.
If you prompt:
“Use Page Object Model and store locators in separate page files.”
The generator will output something like:
pages/login.page.ts
tests/login/login.spec.ts
Where:
- login.page.ts contains locator definitions and reusable page actions
- login.spec.ts uses the page object and seed data for test logic
The Agentic Loop: From Plan to Stable Tests
When you use all three agents together, you get:
Stable Automation Suite
How Playwright Agents Differ from Generic AI Tools
It’s easy to confuse Playwright Agents with other AI coding tools, such as:
- Cursor AI
- ChatGPT code generation
- Generic AI assistants
| Feature | Regular AI Code Generation | Playwright Agents |
|---|---|---|
| Generates code based on prompts | Yes | Yes |
| Runs tests | No | Yes |
| Fixes failing tests autonomously | No | Yes |
| Understands live DOM while generating code | No | Yes |
| Integrated into the Playwright ecosystem | No | Yes |
Playwright Agents integrate with MCP (Model Context Protocol) and interact with your application and tests as part of the lifecycle. This makes them far more context-aware and useful than simple prompt-to-code generation.
Best Practices for Using Playwright Test Agents
Here are some practical tips based on real usage trends:
Provide Good Context
- Always include a clear seed test
- Use structured seed data
- Reference environment details
Write Clear Prompts
Make sure your prompts include architecture preferences, test data references, and expected outputs.
Review Generated Tests
AI can generate great boilerplate, but human review is still important.
Integrate into CI Carefully
Conclusion
Playwright Agents, Planner, Generator, and Healer bring AI directly into the automation lifecycle. They:
- Plan test scenarios from natural language
- Generate well-structured automation code
- Check and repair failing tests
- Help QA teams move faster with less manual overhead
For any QA engineer with basic Playwright knowledge, these agents unlock productivity leaps, from planning without code to generating and healing tests with AI.
Subscribe to Our Newsletter
Subscribe to RSS
Press & Media Hub RSS FeedRelated Articles.
More from the engineering frontline.
Dive deep into our research and insights on design, development, and the impact of various trends to businesses.

Jun 19, 2026
We Built a 114-Second AWS-to-Azure Failover. Here’s What We Learned
A practical guide to building a 114-second multi-cloud disaster recovery failover between AWS and Azure — what we built, what broke, and what we learned.

Jun 17, 2026
Google I/O 2026 Mobile Playbook: AI Studio, Android CLI, and Antigravity for App Development
Google I/O 2026 shifted mobile development from code assistance to full lifecycle delivery. This blog breaks down what that means for Android, Flutter, and React Native teams.

Jun 17, 2026
Beyond the Chatbot: Architecting Enterprise Workflows with Managed Agents in the Gemini API
A practical guide to building production-ready agentic workflows with Google's Managed Agents API, covering architecture, governance, and where enterprise teams should start.

Jun 16, 2026
Integrating AI with Wearable Healthcare Apps: Architecture, Compliance & ROI
A technical and compliance-focused guide for U.S. healthcare founders and providers on building AI-enabled wearable healthcare apps across architecture, compliance, and ROI.

Jun 16, 2026
HL7 and FHIR for AI Healthcare Platforms: What It Takes to Build for Production
A practical guide covering the HL7 and FHIR standards, production readiness requirements, implementation roadmap, architecture considerations, and compliance controls that AI healthcare teams need to address before enterprise deployment.

Jun 12, 2026
Cloud-Native and Cloud-Agnostic Are Not Ideologies; They Are Business-Stage Decisions
This blog explains how organizations can balance speed, scalability, and operational flexibility as they grow from startup to enterprise scale.