Self-healing test maintenance

Your test suite dies of maintenance, not of bad coverage

One class rename shouldn't cost your team an afternoon of red builds. TestInspector reads the live DOM, repairs the broken selector on the final retry, and tells you exactly what it changed.

Same test runs on Selenium or Playwright. Enable per test.

The maintenance tax

The failing tests you fix are almost never real bugs

Take a suite of 200 tests. A front-end team ships a component refactor and renames one CSS class. Nothing about the product broke — but every test that pointed at that class now throws NoSuchElementException. Someone triages the red build, confirms the app is fine, edits the selectors, and re-runs. That is the maintenance tax, and it is paid in QA time every release.

Selectors rot

Class names, DOM structure, and ids change with every refactor. Each change silently invalidates the tests that reference it.

Triage is the cost

The expensive part is not the one-line fix. It is a human reading the failure, proving the product is fine, and finding the new selector.

Trust erodes

After enough false alarms, teams start ignoring red builds. A suite nobody trusts stops catching the failures that matter.

A real repair

One selector breaks. The runner fixes it and passes.

Below is a single step whose selector stopped matching after a refactor. Attempt one throws. Before failing the run, the runner reads the DOM at the point of failure, derives a selector that points at an element that actually exists, and retries.

Run · attempt 1Failed
Step under test
#CommandTargetValue
7click.btn-primary.checkout
Result
NoSuchElementException
  no element matches: .btn-primary.checkout

DOM at point of failure:
  <button
    class="button button--primary"
    data-testid="checkout-submit">
    Place order
  </button>
Selector staleThe button still exists. Only the class changed.
Run · final retryPassed
Repaired step
#CommandTargetValue
7click[data-testid="checkout-submit"]
Result
Healed step 7
  from: .btn-primary.checkout
  to:   [data-testid="checkout-submit"]
  grounded against the live DOM

click matched 1 element -> passed
Run complete: 1 healed, 0 failed
HealedRepaired selector points at a real element.

The step stays structured and readable — sequence, command, target, value — so a non-engineer can see what changed and why. No code diff to review, no rerun to babysit.

How the repair is chosen

Grounded, reported, reviewable, and gated

Self-healing is deliberately conservative. It does not guess, it does not run on every attempt, and it never fixes something quietly.

Grounded against the live DOM

The agent reads the DOM present at the moment the step failed and derives the repaired selector from elements that actually exist. It cannot invent a selector that matches nothing.

Gated to the final retry

Healing runs only on the last of up to two retries, and only for tests with auto_retry enabled. A flaky-timing failure that resolves on its own never triggers a repair.

Reported, not silent

Every healed step records the old selector, the new selector, and the fact it was grounded against the DOM. You see the change, not just a green check.

Reviewable and yours to keep

A repair is a proposal you can accept into the stored step or reject. The test definition stays under your control — healing informs it, it does not overwrite your intent behind your back.

One report per run

One email after retries finish — not one per attempt

A run with retries can produce several attempts per step. You do not want an inbox full of them. TestInspector waits until every retry has completed, then sends a single consolidated report listing every step it healed and every step that genuinely failed.

  • Healed steps and real failures are separated, so a green run with repairs never hides a red one.
  • Each healed step lists the old and new selector inline.
  • One message per run keeps the signal high and the noise out.
Run report · checkout suite
Suite: Checkout — nightly
Engine: Playwright
Attempts: retries complete

Healed (1)
  step 7  click
    .btn-primary.checkout
      -> [data-testid="checkout-submit"]

Failed (1)
  step 12  assertText
    expected "Order confirmed"
    found    "Payment declined"

Summary: 23 passed · 1 healed · 1 failed
One report sent for this run.
Questions worth asking

What self-healing does not do

What if it heals the wrong element?
The repaired selector is derived from the DOM present at the point of failure, so it always points at an element that exists on the page. The report shows the exact old and new selector for the step, and the repair is a proposal you review rather than a silent rewrite. If a repair looks wrong, you reject it and the stored step is untouched.
Does it hide real failures?
No. Healing only applies when a selector stops matching. An assertion that fails on a genuine product problem — wrong text, a declined payment, a missing element that should be there — is reported as a failure in the same run report, listed separately from healed steps. A run can be green because of a repair and still surface every real failure it found.
Can I reject a repair?
Yes. A repair is proposed against the stored step, not forced into it. You choose whether to accept the new selector into the test definition or keep the original. The test stays structured and under your control either way.
Does it run on every failure?
No. Self-healing is gated to the final retry attempt, applies only to tests with auto_retry enabled, and retries are capped at roughly two. A transient failure that clears on its own never triggers a repair.
Does it work on both engines?
Yes. The same structured test runs on Selenium or Playwright, and healing behaves the same way on either. You are not locked into one engine to get it.

Stop paying the maintenance tax on your test suite

Enable auto_retry on a test, break a selector on purpose, and watch the run repair itself and tell you what it did.