File: test-agents.md | Updated: 11/18/2025
On this page
Introductionβ
Playwright comes with three Playwright Test Agents out of the box: π planner, π generator and π healer.
These agents can be used independently, sequentially, or as the chained calls in the agentic loop. Using them sequentially will produce test coverage for your product.
Start with adding Playwright Test Agent definitions to your project using the init-agents command. These definitions should be regenerated whenever Playwright is updated to pick up new tools and instructions.
VS Code
Claude Code
OpenCode
npx playwright init-agents --loop=vscode
npx playwright init-agents --loop=claude
npx playwright init-agents --loop=opencode
note
VS Code v1.105 (currently on the VS Code Insiders channel ) is needed for the agentic experience in VS Code. It will become stable shortly, we are a bit ahead of the curve with this functionality!
Once the agents have been generated, you can use your AI tool of choice to command these agents to build Playwright Tests.
π Plannerβ
Planner agent explores your app and produces a test plan for one or many scenarios and user flows.
Input
seed test that sets up the environment necessary to interact with your appPrompt

- Notice how the
seed.spec.tsis included in the context of the planner.- Planner will run this test to execute all the initialization necessary for your test including the global setup, project dependencies and all the necessary fixtures and hooks.
- Planner will also use this seed test as an example of all the generated tests. Alternatively, you can mention the file name in the prompt.
Example: seed.spec.ts
import { test, expect } from './fixtures';test('seed', async ({ page }) => { // this test uses custom fixtures from ./fixtures});
Output
specs/basic-operations.md.Example: specs/basic-operations.md
# TodoMVC Application - Basic Operations Test Plan## Application OverviewThe TodoMVC application is a React-based todo list manager that demonstrates standard todo application functionality. The application provides comprehensive task management capabilities with a clean, intuitive interface. Key features include:- **Task Management**: Add, edit, complete, and delete individual todos- **Bulk Operations**: Mark all todos as complete/incomplete and clear all completed todos - **Filtering System**: View todos by All, Active, or Completed status with URL routing support- **Real-time Counter**: Display of active (incomplete) todo count- **Interactive UI**: Hover states, edit-in-place functionality, and responsive design- **State Persistence**: Maintains state during session navigation## Test Scenarios### 1. Adding New Todos**Seed:** `tests/seed.spec.ts`#### 1.1 Add Valid Todo**Steps:**1. Click in the "What needs to be done?" input field2. Type "Buy groceries"3. Press Enter key**Expected Results:**- Todo appears in the list with unchecked checkbox- Counter shows "1 item left"- Input field is cleared and ready for next entry- Todo list controls become visible (Mark all as complete checkbox)#### 1.2 Add Multiple Todos...
π Generatorβ
Generator agent uses the Markdown plan to produce executable Playwright Tests. It verifies selectors and assertions live as it performs the scenarios. Playwright supports generation hints and provides a catalog of assertions for efficient structural and behavioral validation.
Input
specs/Prompt

- Notice how the
basic-operations.mdis included in the context of the generator.- This is how generator knows where to get the test plan from. Alternatively, you can mention the file name in the prompt.
Output
tests/Example: tests/add-valid-todo.spec.ts
// spec: specs/basic-operations.md// seed: tests/seed.spec.tsimport { test, expect } from '../fixtures';test.describe('Adding New Todos', () => { test('Add Valid Todo', async ({ page }) => { // 1. Click in the "What needs to be done?" input field const todoInput = page.getByRole('textbox', { name: 'What needs to be done?' }); await todoInput.click(); // 2. Type "Buy groceries" await todoInput.fill('Buy groceries'); // 3. Press Enter key await todoInput.press('Enter'); // Expected Results: // - Todo appears in the list with unchecked checkbox await expect(page.getByText('Buy groceries')).toBeVisible(); const todoCheckbox = page.getByRole('checkbox', { name: 'Toggle Todo' }); await expect(todoCheckbox).toBeVisible(); await expect(todoCheckbox).not.toBeChecked(); // - Counter shows "1 item left" await expect(page.getByText('1 item left')).toBeVisible(); // - Input field is cleared and ready for next entry await expect(todoInput).toHaveValue(''); await expect(todoInput).toBeFocused(); // - Todo list controls become visible (Mark all as complete checkbox) await expect(page.getByRole('checkbox', { name: 'β―Mark all as complete' })).toBeVisible(); });});
π Healerβ
When the test fails, the healer agent:
Input
Prompt

Output
Artifacts and Conventionsβ
The static agent definitions and generated files follow a simple, auditable structure:
repo/ .github/ # agent definitions specs/ # human-readable test plans basic-operations.md tests/ # generated Playwright tests seed.spec.ts # seed test for environment tests/create/add-valid-todo.spec.ts playwright.config.ts
Under the hood, agent definitions are collections of instructions and MCP tools. They are provided by Playwright and should be regenerated whenever Playwright is updated.
Example for Claude Code subagents:
npx playwright init-agents --loop=vscode
specs/βSpecs are structured plans describing scenarios in human-readable terms. They include steps, expected outcomes, and data. Specs can start from scratch or extend a seed test.
tests/βGenerated Playwright tests, aligned one-to-one with specs wherever feasible.
seed.spec.tsβSeed tests provide a ready-to-use page context to bootstrap execution.