Your Self-Healing Test Passed. Did It Click the Right Button?
Suneet Malhotra
Nov 15, 2026
A self-healing test that passes has proved one thing: the new locator found something clickable. It has not proved that the test still checks what its author meant. When the repair lands on the wrong element and the run still goes green, that is a false heal, and a green dashboard will never show it to you.
This post gives a short check you can run on any AI test repair before you merge it. The page, locators, and outcomes below are a synthetic example, not data from a real product.
What is a false heal?
A false heal is an automated locator repair that restores execution without restoring intent. The test runs again. The assertion passes. The element under test is no longer the one the test was written for.
It is worse than a flaky test. A flaky test is noisy and people complain about it. A false heal is quiet, and it removes coverage while the suite reports full health.
A synthetic example
Take a checkout page with two buttons that look alike to a model reading the DOM:
<button id="apply-coupon" class="btn btn-primary">Apply</button>
<button id="apply-gift-card" class="btn btn-primary">Apply</button>
The original test targets the coupon button:
await page.locator('#apply-coupon').click();
await expect(page.locator('.order-total')).toBeVisible();
A front-end change renames the id to coupon-apply-btn. The locator breaks. A repair step looks for the nearest match and proposes this:
await page.getByRole('button', { name: 'Apply' }).nth(1).click();
That is the gift-card button. The click works. The order total is still visible, so the assertion passes. The test is green and it no longer tests coupons at all.
Two things made this possible, and both are common:
- The repair was judged by a rerun, and a rerun only checks that the test passes.
- The assertion was too weak to notice which button was clicked.
The five-minute false-heal check
Run these four questions against every healed locator. Any "no" sends the repair to a human.
| Check | Question | In the example |
|---|---|---|
| Identity | Is the new element the same control as the old one, by a stable attribute such as a test id, accessible name plus container, or form field name? | No. Different control. |
| Uniqueness | Does the new locator match exactly one element without a positional index? | No. It needs .nth(1). |
| Effect | Does the assertion fail if you click a neighbouring element instead? | No. The total is visible either way. |
| Diff | Did the repair change only the locator, and leave the assertion alone? | Yes. |
The effect check is the one most teams skip, and it is the cheapest. Point the healed test at the wrong button on purpose. If it still passes, the test could not have caught the false heal, and it cannot catch a real regression in that feature either.
Fix the assertion, then accept the repair
In the example, the right repair is page.locator('#coupon-apply-btn'), or better, a test id that survives the next rename. The assertion should name the effect of the action:
await page.getByTestId('apply-coupon').click();
await expect(page.getByTestId('discount-line')).toHaveText('-$10.00');
Now a click on the gift-card button fails the test, which is the behaviour you want from a regression test.
Treat the repair as a proposal
The model is useful for narrowing the search. It should not also be the judge of its own fix. A workable split:
- The repair step proposes a new locator and records the old one, the new one, and the DOM around both.
- A separate gate runs the identity and uniqueness checks automatically.
- Repairs that pass go into a pull request like any other code change. Repairs that fail go to a person.
- Count the repairs a person rejects. That count is your false-heal rate, and it is the number to watch, more than the pass rate.
Limits
This check covers locator repairs. It does not cover repairs that rewrite assertions or test data; those change the meaning of the test by design and should always be reviewed by a person. Stable attributes also have to exist. If the application has no test ids or meaningful accessible names, the identity check has nothing to compare, and adding them is the first job.
Further reading
I studied this failure mode in a peer-reviewed article in the Journal of Systems and Software: LLM self-healing of web locators as assisted triage. A shorter version of the argument is in InfoWorld: Your AI testing dashboards are green. That's the problem.
If your suite heals itself, pick one healed test today and click the wrong button on purpose. What happened?
Share this post
You Might Also Like
Test AI Stream Failure Before Saving the Answer
A stream can deliver plausible text and still fail. Interrupt a synthetic response, then check the UI, saved record, and completion metric before trusting success.
AI & AutomationTest Agent Approval Against Changed Tool Arguments
An agent can execute different arguments from the ones you approved. Pause the workflow, mutate one field, and test the actual write against the reviewed snapshot.
Career & Best PracticesThe Cheapest Test Is the One You Run Before You Build
The most expensive engineering mistakes in my systems were not hard bugs. They were reasonable implementations of questions nobody had defined.
Quantitative TradingA Signal Is Not a Decision
A signal says that conditions are interesting. It does not say that the portfolio should trade. The missing layer is the decision record between detection and execution.
Latest Blog Posts
Test AI Stream Failure Before Saving the Answer
A stream can deliver plausible text and still fail. Interrupt a synthetic response, then check the UI, saved record, and completion metric before trusting success.
Test Agent Approval Against Changed Tool Arguments
An agent can execute different arguments from the ones you approved. Pause the workflow, mutate one field, and test the actual write against the reviewed snapshot.
Swap Answer Order Before Trusting an AI Judge
An AI judge should pick the same answer after its position changes. Build a swap test, verify winner mapping, and separate order sensitivity from ordinary variation.
Related Tools & Demos
The QA Field Manual to Language Models
A free 24-chapter book. Start at βwhat is AI, really?β and finish with a small language model you built yourself β one that reads a failing Playwright test and proposes a fix you can run. Read it in your browser, or download the PDF or the Mac app.
View Source Code βMulti-Model LLM Harness
One interface to call any AI model β capability routing, fallback chains, budgets, circuit breakers, and a quality feedback loop. A practical architecture pattern write-up.
Automated Trading System
Multi-engine trading platform with real-time risk management, regime-based strategy selection, and automated order execution.
View Source Code β
Stay in the Loop
Get weekly insights on AI-driven QA, engineering leadership, and automation strategies.
No spam, ever. Unsubscribe anytime.