If you have spent the last few years writing Playwright tests by hand — crafting locators, building page objects, maintaining assertion chains across every sprint — you know how much time goes into keeping a test suite alive. A 300-test suite for a SaaS application can easily demand 15–20 hours per sprint just in maintenance: fixing broken selectors, updating expected values, adapting to new UI layouts.
Playwright test agents change the equation. Instead of you writing every test and chasing every failure, three specialized AI agents handle the pipeline: one plans what to test, one generates the Playwright code, and one heals tests when they break. This is not a wrapper or a third-party plugin — it is built directly into Playwright starting with v1.56.
This guide covers each agent in detail, how the pipeline connects, configuration, ARIA snapshots (the foundation of how agents understand your app), comparisons with other AI testing approaches, and a full real-world workflow with code at every step.
What Are Playwright Test Agents?
Playwright test agents are a three-agent AI system introduced in Playwright v1.56 that automates the test lifecycle. Rather than a single monolithic AI that tries to do everything, the work is divided into three focused agents with distinct responsibilities:
- Planner Agent — Analyzes your application's page structure and identifies test scenarios. It reads the accessibility tree, determines user flows worth testing, and produces structured test plans.
- Generator Agent — Takes the planner's output and writes complete, runnable Playwright test files in TypeScript. It uses ARIA snapshots (not screenshots) to choose reliable locators.
- Healer Agent — Monitors test execution. When a test fails due to a stale selector, changed text, or restructured DOM, the healer diagnoses the issue and patches the test code automatically.
The critical distinction between Playwright agents and earlier AI testing tools is the ARIA snapshot foundation. Previous tools relied on screenshots and pixel-based analysis, which is slow, brittle, and struggles with dynamic content. Playwright agents use the accessibility tree — the same structured representation screen readers use — giving them a semantic understanding of every element on the page: its role, label, state, and relationship to other elements.
Version requirement: Playwright test agents require v1.56 or later. If you are on an older version, run npm install @playwright/test@latest to upgrade. The agent feature is opt-in — it does not affect existing tests unless you explicitly enable it in your configuration.
How the Agent Pipeline Works
The three agents operate in a sequential pipeline, with each agent's output feeding into the next. Here is the full architecture:
Application URL / User Story | v +------------------------+ | PLANNER AGENT | <-- Captures ARIA snapshot, identifies test scenarios +------------------------+ | Structured test plan (JSON) v +------------------------+ | GENERATOR AGENT | <-- Writes Playwright TypeScript from plan + ARIA tree +------------------------+ | Complete .spec.ts files v +------------------------+ | TEST EXECUTION | <-- npx playwright test (standard runner) +------------------------+ | pass / fail results v +------------------------+ | HEALER AGENT | <-- Reads failure + new ARIA snapshot, patches code +------------------------+ | v Healed test OR bug report
The pipeline is designed to be iterative. When the healer patches a test, it feeds back into the test execution step. This loop continues until all tests pass or the healer determines that the failure is a genuine application bug rather than a stale test. In practice, most UI-change-related failures are resolved in one or two healing cycles.
The planner and generator can also be run independently. You might use the planner alone to generate a test plan for manual review, or the generator alone to write tests from a plan you wrote by hand. The healer runs automatically whenever tests fail, requiring no manual trigger.
Setting Up Playwright Test Agents
Setting up Playwright test agents requires three steps: installing the latest Playwright, configuring an LLM provider, and enabling agent mode in your config file.
Step 1: Install or Upgrade Playwright
# New project npm init playwright@latest # Existing project — upgrade to v1.56+ npm install @playwright/test@latest npx playwright install
Step 2: Initialise Playwright Agents
Run the init agents command to scaffold agent configuration for your environment:
npx playwright init agents
You will be prompted to choose a loop — the IDE or AI tool driving the agent workflow:
| Loop value | What it configures | Requirement |
|---|---|---|
claude |
Claude Code via terminal — recommended | Claude Code CLI installed |
vscode |
GitHub Copilot Agent inside VS Code | VS Code v1.105+ |
codex |
OpenAI Codex CLI agent | Codex CLI installed |
opencode |
OpenCode CLI agent | OpenCode CLI installed |
Claude loop recommended: The claude loop produces the best test quality because Claude understands Playwright's semantic locator API and generates idiomatic TypeScript with correct async/await patterns. If you are using VS Code with GitHub Copilot, choose vscode instead.
Step 3: Configure Your LLM Provider
Playwright agents need an LLM to power the planning, generation, and healing. You configure this in playwright.config.ts:
import { defineConfig } from '@playwright/test'; export default defineConfig({ // Standard Playwright config testDir: './tests', use: { baseURL: 'http://localhost:3000', trace: 'on-first-retry', }, // Agent configuration (v1.56+) agent: { // LLM provider: 'anthropic' | 'openai' | 'azure-openai' provider: 'anthropic', // Model to use (Claude recommended for test generation) model: 'claude-sonnet-4-20250514', // API key (use env variable in production) apiKey: process.env.ANTHROPIC_API_KEY, // Enable specific agents planner: true, generator: true, healer: true, // Healer: max repair attempts per failing test maxHealAttempts: 3, // Generator: output directory for generated tests outputDir: './tests/generated', }, });
Step 4: Set Your API Key
# macOS / Linux export ANTHROPIC_API_KEY="sk-ant-..." # Windows PowerShell $env:ANTHROPIC_API_KEY = "sk-ant-..."
Security note: Never commit API keys to your repository. Use environment variables or a secrets manager. In CI/CD, store the key as a pipeline secret (e.g., GitHub Actions secrets, Azure DevOps variable groups).
The Planner Agent
The planner agent is the entry point of the pipeline. Its job is to analyze your application and identify what should be tested. It does this by capturing an ARIA snapshot of each page, parsing the accessibility tree, and reasoning about which user interactions are possible and which outcomes should be verified.
You invoke the planner by pointing it at a URL or a set of routes:
# Plan tests for a specific page npx playwright test --agent plan --url http://localhost:3000/checkout # Plan tests for multiple routes npx playwright test --agent plan --url http://localhost:3000/login \ --url http://localhost:3000/dashboard \ --url http://localhost:3000/settings
The planner navigates to each URL, captures the ARIA snapshot, and produces a structured plan. Here is an example of planner output for a checkout page:
{
"page": "/checkout",
"scenarios": [
{
"id": "checkout-happy-path",
"title": "Complete checkout with valid payment",
"category": "happy_path",
"steps": [
"Fill shipping address form (name, address, city, zip)",
"Select standard shipping",
"Enter valid credit card details",
"Click Place Order button"
],
"assertions": [
"Order confirmation page is displayed",
"Order number is visible",
"Cart is emptied"
]
},
{
"id": "checkout-invalid-card",
"title": "Checkout with invalid credit card shows error",
"category": "negative",
"steps": [
"Fill shipping address form",
"Enter invalid credit card number",
"Click Place Order button"
],
"assertions": [
"Error message: Invalid card number",
"User remains on checkout page",
"Form data is preserved"
]
},
{
"id": "checkout-empty-fields",
"title": "Submit checkout with empty required fields",
"category": "negative",
"steps": [
"Leave all fields empty",
"Click Place Order button"
],
"assertions": [
"Validation errors appear for each required field",
"Place Order button remains visible"
]
}
]
}
The planner's strength is coverage breadth. It systematically identifies happy paths, negative cases, edge cases (empty inputs, boundary values), and accessibility-related scenarios (keyboard navigation, screen reader labels) — scenarios that human testers often skip under time pressure. Because it reads the ARIA snapshot, it knows exactly which form fields exist, which buttons are enabled, and which interactive elements are present.
The Generator Agent
The generator agent takes the planner's structured output and writes complete, runnable Playwright test files in TypeScript. It does not produce pseudocode or partial snippets — it outputs files you can execute immediately with npx playwright test.
# Generate tests from a plan file npx playwright test --agent generate --plan ./checkout-plan.json # Plan + generate in one step npx playwright test --agent generate --url http://localhost:3000/checkout
Here is what the generator produces for the happy-path checkout scenario:
import { test, expect } from '@playwright/test'; test.describe('Checkout', () => { test('complete checkout with valid payment', async ({ page }) => { await page.goto('/checkout'); // Fill shipping address await page.getByLabel('Full name').fill('Jane Smith'); await page.getByLabel('Street address').fill('123 Main St'); await page.getByLabel('City').fill('Austin'); await page.getByLabel('ZIP code').fill('78701'); // Select shipping method await page.getByRole('radio', { name: 'Standard shipping' }).check(); // Enter payment details await page.getByLabel('Card number').fill('4242424242424242'); await page.getByLabel('Expiration').fill('12/28'); await page.getByLabel('CVC').fill('123'); // Place order await page.getByRole('button', { name: 'Place Order' }).click(); // Verify confirmation await expect(page.getByRole('heading', { name: 'Order Confirmed' })).toBeVisible(); await expect(page.getByText(/Order #\d+/)).toBeVisible(); }); test('invalid credit card shows error', async ({ page }) => { await page.goto('/checkout'); // Fill shipping address await page.getByLabel('Full name').fill('Jane Smith'); await page.getByLabel('Street address').fill('123 Main St'); await page.getByLabel('City').fill('Austin'); await page.getByLabel('ZIP code').fill('78701'); // Enter invalid card await page.getByLabel('Card number').fill('0000000000000000'); await page.getByRole('button', { name: 'Place Order' }).click(); // Verify error await expect( page.getByText('Invalid card number') ).toBeVisible(); // User stays on checkout await expect(page).toHaveURL(/\/checkout/); }); });
Notice the locator strategy. The generator uses getByRole() and getByLabel() — semantic, accessibility-based locators that come directly from the ARIA snapshot. It does not use CSS selectors like .form-field-3 > input or XPath. This makes the generated tests inherently more resilient to DOM restructuring, because ARIA roles and labels change far less frequently than CSS class names.
The Healer Agent
The healer is what makes Playwright agents truly autonomous. When you run your test suite and a test fails, the healer automatically analyzes the failure, captures a fresh ARIA snapshot of the current page state, compares it against the snapshot the test was originally generated from, and patches the test code to match the new state.
You do not invoke the healer manually. It activates automatically when tests fail:
# Run tests — healer activates automatically on failures npx playwright test --agent heal # Run with verbose healing output npx playwright test --agent heal --agent-verbose
Here is a concrete example. Suppose a developer renames the "Place Order" button to "Complete Purchase" in the next sprint. Your test has this locator:
// This line fails: button text changed await page.getByRole('button', { name: 'Place Order' }).click(); // Error: locator resolved to 0 elements
The healer detects the failure, captures a new ARIA snapshot, finds the button with the updated label, and rewrites the locator:
// Healer patched: "Place Order" → "Complete Purchase" await page.getByRole('button', { name: 'Complete Purchase' }).click();
The healer handles more than simple text changes. It can resolve:
- Renamed labels and buttons — text content changes
- Restructured forms — fields moved to different sections
- Changed ARIA roles — e.g., a
<div>replaced with a<button> - New intermediate steps — e.g., a confirmation modal inserted before submission
- Removed elements — detects when an element no longer exists and flags it as a potential bug
The healer's resolution rate depends on the complexity of the change. For straightforward selector updates (renamed labels, moved elements), it resolves 85–95% of failures without human intervention. For structural changes like new multi-step flows, it resolves roughly 60–70% and flags the rest for manual review.
Failure Triage: What the Healer Does with Each Failure Type
The healer classifies every failure into one of four categories before deciding how to respond:
| Failure type | Diagnosis signal | Healer action |
|---|---|---|
| Locator break | Element not found; ARIA snapshot shows a matching element with different name/role | Auto-patches locator in test file, re-runs to confirm ✅ |
| Environment issue | Network timeout, server error, or test data missing — not a code problem | Flags as environment failure, skips healing, surfaces in report ⚠️ |
| Actual bug | Assertion fails because app behaviour changed (e.g., wrong total calculated) | Does NOT heal — flags as genuine regression for human review 🐛 |
| Design change | Flow restructured (e.g., single-page checkout split into 3 steps) | Flags for replanning — regenerate from planner with updated ARIA snapshot 🔄 |
Healing limit: The maxHealAttempts config option (default: 3) caps how many times the healer retries a single test. If a test still fails after 3 healing cycles, it is flagged as needing manual attention — likely a genuine application bug rather than a stale test.
ARIA Snapshots: The Foundation
The single most important architectural decision in Playwright's agent system is the use of ARIA snapshots instead of screenshots. Understanding why matters for anyone using or evaluating these agents.
An ARIA snapshot is a serialized representation of the page's accessibility tree. Every rendered page has an accessibility tree — a hierarchical structure that describes each element's role (button, textbox, heading, link), its accessible name (label text), its state (checked, disabled, expanded), and its relationships (parent, child, described-by). Screen readers use this tree to present pages to visually impaired users. Playwright agents use it to understand pages programmatically.
Here is what an ARIA snapshot looks like for a simple login form:
- heading "Sign In" [level=1] - form "Login form" - textbox "Email address" [required] - textbox "Password" [required] [type=password] - checkbox "Remember me" - button "Sign In" - link "Forgot your password?" - paragraph "Don't have an account?" - link "Create one"
Compare this with a screenshot approach. A screenshot is a rasterized image — pixels on a grid. To extract meaning from it, an AI must run OCR, infer element boundaries, guess which text is a label versus a heading, and estimate click targets. This is computationally expensive, error-prone with dynamic content, and loses all semantic information about roles and states.
The ARIA snapshot gives the agent direct access to the semantic structure. The agent knows that "Email address" is a textbox, that it is required, and that "Sign In" is a button — without any visual processing. This is why Playwright agents can generate getByRole() and getByLabel() locators that are both reliable and human-readable.
Why ARIA Snapshots Beat Screenshots for AI Agents
- Speed: Capturing an ARIA snapshot takes milliseconds. Processing a screenshot with vision models takes seconds.
- Precision: ARIA snapshots provide exact element identities. Screenshots require inference about what is clickable.
- Reliability: ARIA snapshots are deterministic. Screenshots vary with rendering engine, font loading, and viewport size.
- Token efficiency: An ARIA snapshot for a complex page is typically 2–5 KB of text. A screenshot description can consume 10–50x more tokens.
- Semantic awareness: ARIA snapshots encode element states (disabled, checked, expanded) that are invisible in screenshots.
Playwright Agents vs Claude AI + MCP Server
If you are already using Claude AI with the Playwright MCP Server for agentic testing, you might wonder how Playwright's built-in agents compare. The answer is that they serve complementary roles.
Playwright Built-in Agents
- Operate within the Playwright test runner — no external tool configuration
- Use ARIA snapshots natively — zero setup for accessibility-based locators
- Tight integration with
playwright.config.ts— one config file for everything - Best for: automated test generation and maintenance within an existing Playwright project
- Limitation: follow a structured pipeline — less flexibility for ad-hoc exploration
Claude AI + MCP Server
- Full conversational interface — you can ask Claude to explore, investigate, debug
- Live browser interaction through MCP — screenshots, network interception, JS evaluation
- Can generate tests for any framework, not just Playwright
- Best for: exploratory testing, complex debugging, cross-framework generation, and learning
- Limitation: requires MCP Server setup and Claude API access
The most effective teams in 2026 use both. Playwright built-in agents handle the day-to-day pipeline: generate tests for new features, heal broken ones during CI, and maintain coverage automatically. Claude AI + MCP Server handles the work that requires reasoning: investigating flaky tests, debugging cross-browser issues, generating tests for complex business logic, and exploring application behavior interactively. For a detailed walkthrough of the MCP Server approach, see our Playwright MCP Server setup guide.
Pro tip: You can use Claude AI to review and improve tests generated by Playwright's built-in agents. Feed the generated .spec.ts files to Claude and ask it to evaluate locator resilience, add edge-case assertions, and optimize test structure. This gives you the speed of automated generation with the quality of human-level review.
Real-World Agent Workflow Example
Let us walk through a complete workflow from start to finish. We have an e-commerce application running at http://localhost:3000 and we want to generate tests for the product search feature.
Step 1: Planner Analyzes the Search Page
npx playwright test --agent plan --url http://localhost:3000/products
The planner navigates to /products, captures the ARIA snapshot, and outputs a plan:
{
"page": "/products",
"ariaSnapshot": "heading 'Products' [level=1] → searchbox 'Search products' → ...",
"scenarios": [
{
"id": "search-valid-query",
"title": "Search with valid product name returns results",
"steps": ["Type 'wireless headphones' in search", "Press Enter"],
"assertions": ["Product cards displayed", "Result count visible"]
},
{
"id": "search-no-results",
"title": "Search with gibberish query shows no results message",
"steps": ["Type 'xyzabc123' in search", "Press Enter"],
"assertions": ["No results message visible", "Search query reflected in message"]
},
{
"id": "search-empty-submit",
"title": "Submit empty search shows all products",
"steps": ["Clear search field", "Press Enter"],
"assertions": ["All products displayed", "No filter indicators"]
},
{
"id": "search-keyboard-navigation",
"title": "Search results are keyboard-navigable",
"steps": ["Type 'headphones'", "Press Enter", "Tab to first result", "Press Enter"],
"assertions": ["Product detail page opens", "Focus visible on interaction"]
}
]
}
Step 2: Generator Writes the Tests
npx playwright test --agent generate --plan ./search-plan.json
import { test, expect } from '@playwright/test'; test.describe('Product Search', () => { test.beforeEach(async ({ page }) => { await page.goto('/products'); }); test('valid search returns matching products', async ({ page }) => { const searchBox = page.getByRole('searchbox', { name: 'Search products' }); await searchBox.fill('wireless headphones'); await searchBox.press('Enter'); // Verify results appear const productCards = page.getByRole('article'); await expect(productCards).not.toHaveCount(0); // Verify result count is displayed await expect( page.getByText(/\d+ results? for/) ).toBeVisible(); }); test('gibberish search shows no results', async ({ page }) => { const searchBox = page.getByRole('searchbox', { name: 'Search products' }); await searchBox.fill('xyzabc123'); await searchBox.press('Enter'); await expect( page.getByText(/no results/i) ).toBeVisible(); }); test('empty search shows all products', async ({ page }) => { const searchBox = page.getByRole('searchbox', { name: 'Search products' }); await searchBox.clear(); await searchBox.press('Enter'); // All products visible — expect multiple cards const productCards = page.getByRole('article'); await expect(productCards).toHaveCount({ minimum: 5 }); }); });
Step 3: Healer Fixes a Broken Test
Two sprints later, the design team renames the search box placeholder from "Search products" to "Find items..." and changes the results display. Your tests fail:
npx playwright test --agent heal Running 3 tests... FAIL valid search returns matching products → getByRole('searchbox', { name: 'Search products' }) resolved to 0 elements Healer: Capturing fresh ARIA snapshot... Healer: Found searchbox with name "Find items..." Healer: Patching locator → getByRole('searchbox', { name: 'Find items...' }) Healer: Re-running test... PASS valid search returns matching products (healed) 3 tests: 3 passed (2 healed) Healed files written to tests/generated/product-search.spec.ts
The healer updated the locator in the test file. The fix persists — you can commit the healed file to your repository. No human intervention required.
Limitations and Best Practices
Playwright test agents are powerful but not omniscient. Understanding their limitations is essential for using them effectively.
What Agents Cannot Do
- Complex business logic validation: An agent can verify that a discount is applied, but it cannot verify that the discount calculation follows your specific business rules without being told those rules explicitly.
- Data-dependent assertions: If a test requires specific database state (e.g., "user has 3 items in cart"), agents cannot set up that state. You still need test fixtures and data seeding.
- Third-party integrations: Tests that depend on external services (payment gateways, email verification) require mocking. Agents do not automatically configure mocks.
- Performance testing: Agents test functionality, not performance. They will not tell you that your checkout takes 8 seconds to load.
- Visual regression: ARIA snapshots do not capture visual appearance. A button with the right label but wrong color will pass agent-generated tests. Use Playwright's visual comparison features separately.
Best Practices
- Always review generated tests before merging. Agents write correct code, but they may miss domain-specific assertions or generate overly broad locators. A 2-minute review catches issues that would cost hours in debugging later.
- Use the planner for coverage analysis. Run the planner against all your routes and compare its output to your existing test suite. The gap shows you what you are missing.
- Set
maxHealAttemptsto 3. Higher values waste LLM tokens on tests that genuinely need human attention. Lower values trigger false alarms. - Commit healed tests. When the healer patches a test, commit the updated file. This keeps your test suite in sync with the application and provides a clear audit trail.
- Combine with Claude AI for complex scenarios. Use built-in agents for bulk generation and maintenance. Use Claude AI for test generation when you need conversational reasoning about complex flows.
Human review is non-negotiable. The teams that get burned by AI-generated tests are those that merge without reviewing. Agents are tools that produce drafts. The QA engineer's role shifts from writing tests to reviewing and approving them — that role does not disappear.
Master AI Testing: Playwright Agents + Claude AI Course
Playwright's built-in agents handle automated generation and healing. Claude AI + MCP Server handles interactive exploration and complex reasoning. Together, they form the most complete AI testing toolkit available in 2026.
The Playwright + Claude AI & MCP Server course on Udemy covers both approaches in depth:
- Setting up Playwright test agents (planner, generator, healer) from scratch
- Configuring the Playwright MCP Server for Claude AI integration
- ARIA snapshot analysis and locator strategy
- Building agentic testing pipelines for CI/CD
- Self-healing locator patterns for production test suites
- Real-world projects: e-commerce, SaaS dashboards, multi-step forms
Whether you are a QA engineer looking to multiply your output, a developer tired of maintaining brittle tests, or a team lead evaluating AI testing tools — this course gives you the practical skills to ship AI-powered automation confidently.
Frequently Asked Questions
Are Playwright test agents free?
Yes. Playwright test agents ship as part of the open-source Playwright package starting with v1.56. There is no separate license or paid tier. You install them with npm install @playwright/test and enable agent mode in your playwright.config.ts. The only cost is LLM API usage (e.g., Anthropic Claude API calls) — Playwright itself charges nothing for the agent feature.
Do Playwright agents replace manual test writing?
Not entirely. Playwright agents excel at generating standard CRUD flow tests, regression coverage, and repetitive UI assertions — handling roughly 60–80% of typical scenarios autonomously. Complex business logic validation, domain-specific edge cases, and tests requiring specific data states still benefit from human authorship. The recommended workflow is to let agents generate a first draft and have a QA engineer review before merging.
How do Playwright agents compare to GitHub Copilot for testing?
GitHub Copilot is a code completion tool — it suggests the next line as you type. Playwright agents are autonomous executors that plan scenarios, write complete test files, run them against a live app, and fix failures without human intervention. Copilot requires you to drive the process line by line; agents operate in a feedback loop. They are complementary: Copilot helps when you manually author tests, while agents handle automated generation and maintenance.
What LLM providers work with Playwright test agents?
Playwright agents support any LLM provider with a compatible API. Officially tested providers include Anthropic Claude (recommended for structured test output), OpenAI GPT-4o, and Azure OpenAI. You configure the provider and API key in playwright.config.ts. Claude is the recommended choice because it produces the most reliable Playwright TypeScript code with correct async/await patterns and idiomatic locator strategies.
Can Playwright agents run in CI/CD pipelines?
Yes. Playwright agents run in any CI/CD environment supporting Node.js — GitHub Actions, GitLab CI, Jenkins, Azure DevOps, CircleCI. Invoke them with npx playwright test --agent and they execute headlessly like standard tests. For CI, the recommended pattern is "heal mode only" — auto-fix broken selectors but do not generate new tests. New test generation happens locally or in a dedicated pipeline with human review.
Which LLM gives the best results with Playwright test agents?
Claude (Anthropic) consistently produces the highest-quality Playwright output. It generates idiomatic getByRole() and getByLabel() locators, correct async/await patterns, and well-structured Page Object Models. GPT-4o works well for generation but tends to produce more CSS selector fallbacks. For the healer specifically, Claude's reasoning about ARIA tree diffs is significantly more accurate than other models at the same price point.
Can Playwright agents work with my existing Page Object Model code?
Yes. The generator agent respects your existing project architecture. If you have Page Object classes in a /pages directory, the agent detects the pattern and generates new tests that import from and extend your existing POMs rather than writing flat test files. Point the generator at your project root and it analyses the existing structure before generating.
How do I stop the healer from changing too much?
Set maxHealAttempts: 1 in your agent config to limit repair to a single pass, and use healer: { scope: 'locators-only' } to restrict healing to locator patches only — preventing the healer from rewriting assertions or test logic. For CI, run healing in dry-run mode first (--agent heal --dry-run) to preview proposed patches before they are applied to your source files.
What is the difference between Playwright agents and Playwright MCP?
Playwright test agents (planner, generator, healer) are a built-in Playwright feature for automating the test lifecycle — they live inside your Playwright project. The Playwright MCP server is a separate tool that gives external AI assistants (Claude Code, Cursor, Copilot) live browser access via the Model Context Protocol. They complement each other: MCP gives Claude a live browser for exploration, while agents handle structured test generation and maintenance inside the codebase.
Do Playwright agents work with component testing?
Playwright agents currently focus on end-to-end (browser) tests. Component testing with @playwright/experimental-ct-react and similar packages is not yet supported by the agent pipeline. The planner and generator require a running application URL to capture ARIA snapshots from. Component test support is on the Playwright roadmap but has no confirmed release date as of v1.56.
How do I use Playwright agents with Claude Code specifically?
Run npx playwright init agents and select claude as your loop. This scaffolds a CLAUDE.md file that instructs Claude Code on how to invoke the planner, generator, and healer. From your terminal, open Claude Code in your project directory and ask it to run the planner against a specific URL. Claude Code will execute npx playwright test --agent plan, review the output, and proceed to generate tests. See the Playwright MCP Server setup guide for connecting Claude Code to a live browser alongside agents.
What minimum Node.js version do Playwright agents require?
Playwright v1.56+ requires Node.js 18 or later. Node.js 20 LTS is recommended for production use. The agent feature has no additional Node.js requirements beyond the base Playwright dependency. Check your version with node --version before upgrading Playwright if you are on an older project.
Asim Noaman
Senior QA Automation Engineer & AI Testing Specialist
With years of hands-on experience building test automation frameworks for production applications, Asim specializes in combining traditional QA methodologies with cutting-edge AI tools. He has helped teams adopt Playwright and AI-driven testing workflows to ship faster with fewer bugs.