In this article, I’ll talk about the Playwright agents introduced with Playwright version 1.56 and walk through the concept with examples.
Playwright 1.56 brings three types of agents into our workflow:
- Planner
- Generator
- Healer
To automatically generate these agents, you can run one of the following commands depending on the AI-powered editor you’re using:
# Visual Studio Code -> Works for Cursor as well
npx playwright init-agents --loop=vscode
# Claude Code
npx playwright init-agents --loop=claude
# Opencode
npx playwright init-agents --loop=opencode
For Cursor users, you can convert the generated file into MDC format and move it under .cursor/rules to continue.
The Planner visits the page you need to test, analyzes it, and generates test cases in Markdown format. We will try these cases on Trendyol’s cart page for that, we want it to add an item to the cart and navigate to the cart before starting the analysis.
After analyzing the page, it creates the test plan in .md format, closes the browser, and completes the process.
When reviewing the generated test plan, we can clearly see that it produces scenarios we actually need. It doesn’t just think functionally when I tested it on a login page, it even generated security related cases (such as XSS vulnerabilities and CSRF protection).
Now, let’s take one of the cases created by the Planner and try to generate the test using the Generator agent. For this example, I’m choosing the case that increases the product quantity.
The test was successfully created. It is able to automatically add the necessary commands I normally use in my basket tests (such as login and adding a random product to the cart) inside the beforeEach, following the exact structure I use in my other spec files. It also generates the test in the same style I use for example, by waiting for responses instead of relying on static waits. This means I don’t have to refactor the test to match my existing code standards.
When I ran this test across the six projects defined in my Playwright config, five passed and one failed. To fix this, we’ll use the Healer agent.
After enabling the Healer, it runs the tests across all projects, identifies flaky parts, and if it doesn’t catch the issue on the first attempt, it retries the failing test several times to reproduce the flaky behavior.
Once it identifies the issue, it applies logical fixes.
Then it applies sensible fixes to the issues it finds.
And here is the result.
Conclusion
Playwright Agents are evolving beyond simple tools that execute test code they now actively contribute to test analysis, maintenance, and even scenario generation. Each agent has its own strengths. For example, the Healer re-runs failing steps, analyzes UI changes, proposes fixes, and retries tests multiple times to detect flaky behavior. The Planner can generate user scenarios we might not even think of and provides highly sensible additional checks for existing tests. The Generator analyzes our existing tests, adds necessary preconditions automatically, and produces new tests that match our coding style. This leads to more consistent test suites and significantly reduces the need for manual adjustments.
With all these capabilities combined, I can confidently say that Playwright Agents bring real value to my testing process in terms of both speed and quality.
For more details, you can read Playwright’s official documentation or watch the YouTube video they shared.
https://playwright.dev/docs/test-agents










Top comments (1)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.