Stop 13 · AI & Modern QA PracticesTopics · 3/7

Self-Healing Test Scripts

Part of the QA Testing Roadmap

In short

A developer renames a button's ID and 40 tests go red overnight, though nothing is really broken. Self-healing tools try to find the element another way and keep going, so you fix locators, not fires.

AI-powered tools that automatically adapt when a locator changes (e.g. an element's ID updates), reducing the maintenance burden that traditionally causes automation suites to break with every UI change.

The purple blob as a dabbawala carries a tiffin through a rearranged office towards the right person.

Think of it like this

The dabbawala who still finds you

Your office rearranges desks overnight. A good dabbawala doesn't give up because desk 14 moved. He knows your face, your name and your floor, and finds you anyway. Self-healing tests remember several clues about an element, not just one.

Watch it happen

A locator heals itself

Test
Healer
Page

find #submit-btn

1/5The test looks for the pay button by its old ID.

The big ideas

What you need to know

Many clues per element

Healing tools store ID, text, role, attributes and position, then match on whatever still fits.

Less maintenance

Small UI changes stop breaking dozens of tests, so the team spends less time fixing locators.

Healing can hide bugs

If the 'Pay' button moved to the wrong place, a healed test may happily click it. Review every heal.

Good locators first

Stable test IDs and role-based locators reduce the need for healing in the first place.

See it in code

Walk through the code

ts
1// A tiny, honest version of "healing": give the test two ways to find one element2const payButton = page3  .getByTestId("pay-now")4  .or(page.getByRole("button", { name: "Pay now" }));5 6await payButton.click();

1/2First try a stable test ID. If that's missing, fall back to the button's visible name.

Playwright's locator.or() matches either option. Commercial tools go further and pick the best match automatically, but the idea is the same.

Save yourself the pain

Common mistakes

Oops

Turning on auto-heal and never reading the heal reports.

Do this instead

Review heals regularly. Accept the good ones into the code, and treat strange ones as possible bugs.

Oops

Using healing to avoid writing good locators.

Do this instead

Healing is a safety net. Stable test IDs and role-based locators are still the foundation.

Your mission

Break and heal

~25 min

Quick check

What's the main risk of self-healing tests?

Go deeper

  1. 1Read a conceptual overview of how self-healing test tools detect and adapt to locator changes.
  2. 2Learn the trade-off: reduced maintenance burden, but less predictable/transparent test behavior.
  3. 3Understand this is an emerging capability, not yet a complete replacement for good locator strategy.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge