AI coding assistants and browser agents such as Playwright MCP can now open your application, click through it and write Playwright tests that pass on the first run. That is genuinely useful. It is also an easy way to end up with hundreds of tests that pass, cost money to run, and would not catch the bugs you care about. The difference is in what you ask the AI to do and how you review the result.
Where AI test generation works well
- Turning written test cases into code. If you have manual test cases, user stories with acceptance criteria or a recorded session, AI converts them into Playwright tests quickly and mostly correctly. The intent comes from a person; the AI does the typing.
- Boilerplate and page objects. Fixtures, page objects, login helpers and test data builders are repetitive, and AI drafts them well.
- Edge cases and negative data. Asking for boundary values, invalid inputs and unusual characters for a form produces a better list than most people write from memory.
- Exploration. A browser agent wandering through the app finds broken links, console errors and dead ends, and suggests candidate tests. Treat its output as a bug report and a to-do list.
- Repair suggestions. When a locator breaks after a UI change, AI is good at proposing the new one. Proposing, not merging.
Where it goes wrong
- Weak assertions. Generated tests often check that a page loaded or a button is visible, not that the business outcome happened. A checkout test that never checks the order total is decoration.
- Testing the bug. An AI that writes tests from the current UI writes tests that assert the current behaviour, bugs included. It cannot know the requirement unless you give it.
- Fragile locators and waits. CSS chains, nth-child selectors and fixed timeouts still appear, especially in longer flows. Insist on role- and label-based locators and Playwright's built-in auto-waiting.
- Shared state. Tests that depend on data created by another test pass alone and fail in parallel.
- Volume over value. Ten slightly different tests of the same path add run time and maintenance without adding coverage.
A review process that keeps the suite reliable
- Start from intent. Give the AI the requirement or acceptance criteria, not just the URL.
- Review assertions first. For each test ask: if this feature broke in the way users would notice, would this test fail?
- Enforce conventions automatically. Lint rules or a review checklist for locators (getByRole, getByLabel, test IDs), no hard waits, independent data per test.
- Burn in before merging. Run every new test many times, in parallel, before it joins the suite. Playwright's
--repeat-eachmakes this easy. - Keep AI out of the run-time verdict. The merged test is ordinary deterministic code. A model deciding at run time whether a test passed makes failures impossible to reproduce.
# burn in new tests before they join the suite
npx playwright test tests/checkout --repeat-each=20 --workers=4What about self-healing tests?
Self-healing, where a tool silently swaps a broken locator for a new one at run time, sounds attractive and hides real problems: sometimes the element moved, sometimes the feature is broken and the "healed" locator points at the wrong thing. We prefer healing as a suggestion: the pipeline proposes the new locator in a pull request and a person approves it. You keep most of the time saving and none of the silent failures.
The realistic gain
Used this way, AI removes much of the typing and boilerplate from test automation and makes exploratory coverage cheap. It does not remove the need for someone who understands what the product must do. The teams that get the most out of it treat generated tests like a junior engineer's pull request: useful, fast, and always reviewed.
This is how we run our AI test automation engagements, usually together with frontend and end-to-end automation. If the new suite is flaky in CI, see how to find and fix flaky tests.