AI-Augmented QA & Modern Tooling · Lesson 4 of 5

Self-Healing Locators — and the False-Pass Risk

Some tools promise to fix broken tests on their own. It sounds great — and often it is — but there's a quiet danger hiding inside, and interviewers love to hear that you know about it.

By Shahriyar · Updated

The idea, in one line

A self-healing locator re-finds an element when its usual way of finding it stops working. A locator is just the address a test uses to find a button or field on the page.

When that address stops matching, the tool looks for the element another way — by nearby text, other attributes, or where it sits on the screen — and keeps the test running instead of failing.

Two guardrails that keep healing honest

  1. A confidence threshold. The tool scores how sure it is about the new match. Below your cutoff, it should fail and ask a human rather than guess.
  2. Heal locators, never assertions. Let it re-find a button, but never let it change what the test checks. An agent allowed to soften the check will eventually soften it just to pass.

See it work

▸ try it
HEAL_THRESHOLD = 0.90   # only trust a very confident match

def find(page, primary, fallbacks):
    if page.exists(primary):
        return page.locate(primary)

    best, score = page.best_match(fallbacks)   # scores candidates 0..1
    if score < HEAL_THRESHOLD:
        raise LocatorError(f"no confident heal ({score:.2f}) for {primary}")

    audit_log(old=primary, new=best, score=score)  # a human reviews this
    return page.locate(best)
    # NOTE: the test's check on order-total stays completely untouched

Read it top to bottom: try the normal address first; if it's gone, find the best backup; if you're not confident enough, stop and fail; and whatever you do, don't touch what the test is checking.

Advanced — always keep an audit log

Every time a heal happens, record the old locator, the new one, and the confidence score. That log lets a human confirm the change to the page was intentional before the new locator is trusted for good. Healing is a helper that flags changes for review — not a rubber stamp that hides them.

Grounded in reporting on self-healing test automation and its silent false-repair risk (Augment Code, Ranorex)

All lessons in AI-Augmented QA & Modern Tooling

  1. Turn a User Story Into Test Cases — Prompt It Like an Engineer
  2. Critique and Prune — Where AI-Generated Tests Go Blind
  3. AI Coding Assistants — What to Hand Off, What to Review
  4. Self-Healing Locators — and the False-Pass Risk
  5. Ship an AI-in-the-Loop Suite Through CI — and Tell the Story