QA AND TEST AUTOMATION · PART 11 · AI TOOLS FOR TESTERS · PLAYWRIGHT · 100 OF 112

Playwright Test Agents: Planner, Generator, Healer

What npx playwright init-agents really sets up (checked on Playwright 1.63): a planner, a generator and a healer, a seed test and a test MCP server with 89 tools. How each agent works, what its instructions tell it to do, and why the healer needs a review gate: on ShopRung, two red tests had two different causes, one of them a real product bug the healer is told to make pass.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 67
  63. 68
  64. 69
  65. 70
  66. 71
  67. 72
  68. 73
  69. 74
  70. 75
  71. 76
  72. 77
  73. 78
  74. 79
  75. 80
  76. 81
  77. 82
  78. 83
  79. 84
  80. 85
  81. 86
  82. 87
  83. 88
  84. 89
  85. 90
  86. 91
  87. 92
  88. 93
  89. 94
  90. 95
  91. 96
  92. 97
  93. 98
  94. 99
  95. 100
  96. 101
  97. 102
  98. 103
  99. 104
  100. 105
  101. 106
  102. 107
  103. 108
  104. 109
  105. 110
  106. 111
  107. 112
1 / 12

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • init-agents
  • planner, generator, healer
  • 89 test tools
  • two red tests, two causes
  • review every healed assertion

Notes

Set it up

One command sets it up. Init agents, with the loop for your coding tool, here Claude Code; others include Codex, Copilot, OpenCode and VS Code. It creates a specs folder for plans, a seed test that sets the starting state, three agent files, and an MCP configuration for Playwright's test server. The agents are plain Markdown prompts with a tool list: read them, they are short, and you can edit them.

init-agents --loop=claude
specs/README.md       plans go here
tests/seed.spec.ts    start state
.claude/agents/
  playwright-test-planner.md
  playwright-test-generator.md
  playwright-test-healer.md
.mcp.json  →  npx playwright
              run-test-mcp-server
loops: claude, codex, copilot,
  opencode, vscode

Planner

The planner runs the seed test to open the app, explores it with browser tools, and saves a Markdown plan: scenarios with steps and expected results, including edge cases and errors, each from a fresh state. This is the cheapest place to review. Check the plan against your requirements before any code exists: an agent only knows what it saw on screen, not that SAVE10 must apply at exactly fifty dollars.

playwright-test-planner.md
25 tools (21 browser and test)
1 planner_setup_page: run the
  seed test, open the page
2 explore with browser_* tools
3 happy paths, edge cases,
  errors
4 planner_save_plan →
  specs/<name>.md
"assume blank/fresh state"

Generator

The generator takes one scenario, performs every step in a real browser, and checks each expectation with verify tools. Then it reads the log of what worked and writes one test per file, with a comment for each step. Because it acted on the real page, its locators usually work. But its expected values come from the plan, or from what the page showed, which may be the bug.

playwright-test-generator.md
23 tools
generator_setup_page
for each step: do it in the
  real browser
browser_verify_text_visible,
  _element_visible, _value
generator_read_log
generator_write_test: one test
  per file, step comments

Healer

The healer runs the tests, debugs each failure, edits the code and repeats until they pass. Its instructions include updating selectors, which is useful, and fixing assertions and expected values, which is dangerous. It is told not to ask questions and to do the most reasonable thing to pass the test. If it believes the test is right, it marks it fix me, which skips it.

playwright-test-healer.md
16 tools: test_run, test_debug,
  Edit, Write, browser_snapshot
fix: "Updating selectors",
  "Fixing assertions and
  expected values"
"do the most reasonable thing
  possible to pass the test"
if sure the test is right:
  mark it test.fixme()

The tools

The agents talk to Playwright's test MCP server. On version one point six three it offers eighty nine tools, about sixty four thousand characters of definitions, so each agent file lists only the tools it needs. We called its test list and test run tools directly against ShopRung: they return the same errors and call logs you would read. The agent files ask for a cloud model, so plans, page content and code go to that provider.

run-test-mcp-server, 1.63
89 tools, about 64,600
  characters of definitions
each agent sees only its list
test_list: 3 tests in 3 files
test_run: runs them, returns
  the errors and call logs
the agents use a cloud model
  (model: sonnet in the files)

Two red tests

We ran both of our ShopRung tests through the test server with the coupon boundary bug on. Both failed, for different reasons. The cart test could not find nineteen ninety nine, because an earlier run had left items in Alice's cart: a test bug, it never resets its data. The coupon test was refused at exactly fifty dollars: a real product bug. Same red, opposite fixes.

test_run output
✘ cart: getByText('$19.99')
  not found
  cause: an earlier run left
  items in Alice's cart
  → a test bug: no reset
✘ coupon: expected "Coupon
  applied", got "This coupon
  needs a subtotal of at least
  $50.00" → product bug

The risk

Now imagine the healer at work. For the cart test, the easy fix is to expect whatever total is on screen, when the real fix is to reset the data. For the coupon test, it could change the expected message to the error, or mark the test fix me. Either way the build turns green and the bug ships. So healed changes go through review, and any change to an expected value needs the requirement behind it.

What a healer may do
  • cart test: change $19.99 to whatever total is shown → wrong, the fix is a data reset
  • coupon test: accept the error message, or test.fixme() → CI goes green, the bug ships
  • gate: a human reviews every change to an assertion, with the requirement id

Use it well

Used well, the agents save time. Let the planner draft, and add the business rules and edges it cannot see. Let the generator draft tests from reviewed plans. Let the healer fix locators and timing, always in a pull request. Never auto merge healed tests, and treat every fix me as a bug ticket. Putting the requirement id in the test name gives the reviewer the truth to check against.

A safe workflow
  • planner: draft plans, then a tester adds rules and edges
  • generator: drafts tests from reviewed plans
  • healer: locator and timing fixes, in a pull request
  • never auto-merge healed tests
  • a fixme needs a bug ticket
  • requirement ids in test names

Common mistakes

Mistakes. Plans nobody reviewed. Expected values copied from whatever the screen showed, which turns today's bugs into tomorrow's expectations. Auto merging healed tests. Fix me without a bug ticket. Treating every red test as a broken test, when some are doing their job. And a seed test that does not reset data, so tests depend on what ran before.

Avoid these
  • plans nobody reviewed
  • expected values copied from the screen
  • auto-merging healed tests
  • fixme without a bug ticket
  • treating every red test as a broken test
  • no data reset in the seed

Say it like this

In the interview: yes, for drafting and for locator fixes, behind review. The planner drafts plans and I add the business rules; the generator writes tests from plans I reviewed. The healer is instructed to make tests pass, so it can hide product bugs. Every changed assertion is reviewed against a requirement, healed tests come as pull requests, and a fix me needs a bug ticket.

In the interview
  • "For drafting and for locator
  • fixes, yes, behind review. The planner drafts and I add the rules; the generator writes from reviewed plans. The healer is told to make tests pass, so it
  • can hide product bugs: every changed assertion is reviewed
  • against a requirement, and a fixme needs a ticket."

Interview questions

Q1What does npx playwright init-agents create?

Three agent definitions (planner, generator, healer) for your AI tool, a seed test, a specs folder for plans and an MCP config for `npx playwright run-test-mcp-server`.

Q2What does the planner produce?

A Markdown test plan in specs/, after exploring the app from the seed test: scenarios with steps and expected results.

Q3How does the generator write a test?

It performs each step in a real browser, verifies expectations, reads the log and writes one test per file with step comments.

Q4What is the healer allowed to change?

Its instructions include updating selectors and "fixing assertions and expected values", and marking a test test.fixme() when it believes the test is right.

Q5Why can a healer be dangerous?

A failing test may be catching a product bug; changing the expected value or marking it fixme turns CI green and lets the bug ship.

Q6How big is the test MCP server?

On Playwright 1.63, 89 tools and about 64,600 characters of definitions; each agent lists only the tools it needs.

Q7How do you use the agents safely?

Review plans, review every healed change in a pull request, require a requirement id for changed assertions, never auto-merge, and file a ticket for every fixme.

Q8Where do the agents send data?

To the model their AI tool uses (the generated files ask for a cloud model), including page content, plans and code.