AI & Automation4 min read

Your Self-Healing Test Passed. Did It Click the Right Button?

S

Suneet Malhotra

Nov 15, 2026

β€’
1 views
Your Self-Healing Test Passed. Did It Click the Right Button? - AI & Automation blog post
πŸ”§Self-Healing TestsπŸ”§PlaywrightπŸ”§AI Test RepairπŸ”§QA Automation

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.

CheckQuestionIn the example
IdentityIs 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.
UniquenessDoes the new locator match exactly one element without a positional index?No. It needs .nth(1).
EffectDoes the assertion fail if you click a neighbouring element instead?No. The total is visible either way.
DiffDid 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:

  1. The repair step proposes a new locator and records the old one, the new one, and the DOM around both.
  2. A separate gate runs the identity and uniqueness checks automatically.
  3. Repairs that pass go into a pull request like any other code change. Repairs that fail go to a person.
  4. 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

Stay in the Loop

Get weekly insights on AI-driven QA, engineering leadership, and automation strategies.

No spam, ever. Unsubscribe anytime.