QA Interview Hub · Knowledge base · Quizzes · Українська
AI-driven Automation
Test agents: planner, generator, healer
Playwright Test Agents: planner, generator, healer
Playwright Test Agents are three ready-made agents shipped with Playwright (from 1.56) working as a chain: planner, generator and healer. The planner explores the application and writes a Markdown plan, the generator turns it into tests, verifying selectors in a live browser, and the healer runs failed tests, proposes a patch and reruns. The plan is model output, so a person reviews it and the healer's patches.
Starting with Playwright 1.56, three ready-made agents for tests ship with the framework. They work as a chain:
- planner — explores the application and creates a Markdown plan of tests in
specs/;
- generator — turns the plan into tests in
tests/, verifying selectors and assertions in a live browser during generation;
- healer — runs the failed tests, looks at the current interface, proposes a patch and reruns the test.
The agents are set up with npx playwright init-agents --loop=<tool>; the documentation lists vscode, claude, codex and opencode. The command creates agent definitions (instructions and MCP tools) and an example seed test.
Example. You ask: "plan the checkout scenarios". The planner gives specs/checkout.md with scenarios and expected results. You read the plan, delete the extra, add risks, and only then does the generator write tests.
Important: the plan is model output. If it contains an invented scenario or a wrong expected result, the generator will diligently lock the mistake into code.
Common mistakes: running the generator without reviewing the plan; assuming tests written by an agent need no review; not updating the agent definitions after a Playwright update (the documentation advises regenerating them).
Short interview answer: "The planner makes a plan, the generator writes and verifies tests in a browser, the healer repairs failed ones; a person reviews the plan and the patches".
Seed test, init-agents and the workflow
The seed test (tests/seed.spec.ts) sets the agents' initial state: login and data, in its body or via fixtures and global setup. The command init-agents adds the agent definitions; plans go to specs/, tests to tests/. Workflow: the planner writes a plan, a person reviews it, the generator creates tests, the healer fixes failing ones, a person checks the diff. Without login in the seed test or fixtures, agents stall at login.
The generator reports an error: the user is not logged in and there is no order page. The cause is typical: the seed test is empty, and the agents start from it.
What init-agents creates:
- agent definitions (in the documentation, folders such as
.github/): instructions and MCP tools;
tests/seed.spec.ts — the seed test: prepares the environment, provides page and fixtures; exploration and generation start from it;
- a
specs/ folder for Markdown plans and tests/ for generated tests, usually one test per plan.
Workflow:
- in the seed test: login, needed data, base URL — everything the initial state needs;
- the planner reads the request (optionally the requirements too) and writes a plan to
specs/;
- a person reviews the plan: risks, expected results, extra scenarios;
- the generator creates tests; they may contain initial errors;
- the healer repairs the failed ones, or skips a test if it believes the functionality is broken;
- a person reviews the diff and reruns the tests.
Example. After login and a test user are added to the seed test, the generator stops getting stuck on the login page and runs the checkout scenario to the end.
Common mistakes: secrets directly in the seed test or the plan (use environment variables); not pinning the Playwright version; accepting the healer’s result without reviewing the diff.
Short interview answer: "The seed test sets the starting state, planner → generator → healer work as a chain, and my control points are the plan review and the change review".
Self-healing: when healing is right and when it harms
Healing a failed test is right when the interface changed but the behaviour did not: then the locator is updated. If the application broke, that is a defect, not a reason to patch the test. Bad healing keeps a test green at the cost of quality: a weakened assertion, a changed expectation, a longer timeout or a skip. Healer patches go into a PR with a diff and need an explanation.
After a redesign 30 tests failed. The healer made everything green in a few minutes. It is too early to celebrate: you need to know what exactly it changed.
Two kinds of failure:
- the test lags behind the interface — a button was renamed, an element moved, but behaviour is the same; the right healing is to update the locator;
- the application broke — the cart total differs, an action is not performed; the right reaction is a defect, not a test patch.
Bad "healing" keeps a test green at the cost of quality: a weakened assertion (toHaveCount(5) → not.toHaveCount(0)), a changed expected value, an increased timeout, skip. According to the Playwright documentation the healer may skip a test if it believes the functionality is broken; that is a signal for a person, not a reason to hide a line in the report.
Commercial tools often store several attributes of an element and, when the main locator is not found, pick the closest match. The heuristic may choose a similar but wrong element ("Delete" instead of "Cancel"), and the test turns green on the wrong action.
Rule. Healer patches go in a PR with a diff. Changed expectations, new skip and timeout changes need a separate explanation. A locator is normal, an expectation is suspicious.
Common mistakes: auto-commit to main; treating a green run as evidence; not checking that the test still fails on broken behaviour.
Short interview answer: "A locator may be healed when the interface changed and the behaviour did not; a changed expectation or a skip is a reason to look for a defect".