Blog 8 min read
Self-healing tests: what AI should fix, and what it must not
- test-automation
- automation
- software-testing
- quality-assurance
- e2e-testing
The “Pay” button still exists. The user can see it. Yet the automated test fails because its XPath no longer matches the DOM.
This is exactly the kind of problem that makes self-healing attractive: why ask a human to manually update a locator when the intent of the scenario has not changed?
But another question matters far more: how far should AI be allowed to repair the test?
If the system changes the beneficiary, the amount or the expected final state just to get back to PASS, it is no longer repairing the test. It is changing its meaning.
1. Self-healing must preserve one invariant: the business intent
A scenario contains two categories of information that must be kept apart.
The first describes the intent: “transfer €1,000 to this beneficiary and check that the transaction is confirmed”. The second describes the technical mechanism used today to achieve that intent: the button locator, the DOM structure, the WebView context, the wait before an action or the navigation path.
The mechanism can evolve. The intent must not be silently rewritten.
This separation is what makes it possible to define safe self-healing: repair the path, never the expected business truth.
2. Why do locators break?
Interfaces evolve: HTML redesigns, replaced components, dynamic attributes, text changes, a button moved, a new WebView or a new Android hierarchy.
Modern documentation already recommends reducing coupling to technical structure. Playwright advises prioritizing user-facing attributes — role, text, label — or explicit test contracts (test ids), and warns that CSS or XPath selectors tied to the DOM structure can break whenever it changes: long CSS or XPath chains are, according to its documentation, a bad practice that leads to unstable tests.
Selenium likewise recommends keeping locators as compact and readable as possible and, when unique and predictable HTML IDs are available, making them the preferred method.
The best self-healing therefore starts with good selectors. AI must not become an excuse to keep fragile automation.
3. What self-healing can reasonably repair
| Change | Possible repair | Condition |
|---|---|---|
| Locator changed | Find an alternative locator | Same semantic element, sufficient confidence |
| Element moved | Search the new structure | Functional context unchanged |
| Text or label slightly changed | Compare role, neighbors, attributes, history | Low ambiguity |
| Synchronization | Wait for an observable state | Bounded timeout and explicit state |
| WebView, frame or context | Adapt the technical context | Same expected destination |
| Minor navigation | Find the target step again | No critical business step bypassed |
4. What AI must never silently change
- A business assertion. If the test expects “transaction confirmed”, the agent must not accept “transaction pending” to make the scenario pass.
- A critical business value. Amount, beneficiary, product, account number or any other data that is part of the test case must not be changed without an explicit instruction.
- A security rule. OTP, MFA, 3-D Secure, authorization checks or consent steps must not be bypassed because they get in the way of execution.
- A precondition that changes the meaning of the test. If the scenario must test a new beneficiary, the agent must not pick an already registered one just because the journey is easier.
- The expected final result. A test does not become correct because the AI redefined success.
Golden rule — Self-healing = preserving intent despite a technical change. If the repair changes the intent, it is no longer healing: it is a change to the scenario.
5. Why “finding a similar element” is not enough
An AI may find several candidates that are visually or semantically close. Two buttons can both say “Continue”. Two accounts can show similar labels. An element can be visible but covered or disabled.
A healing engine must therefore validate more than textual similarity. It can combine role, text, attributes, relative position, neighbors, history, page context and actionability properties.
Playwright illustrates the importance of that last notion: before a click, it checks in particular that the locator resolves to a single element, and that the element is visible, stable, enabled and able to receive the event.
Scoring must therefore answer two questions: “is this probably the right target?” and “is this target actually usable in the current state?”
6. A controlled self-healing architecture
- Detection — The original locator or action fails.
- Understanding — The engine gathers context: the action’s intent, the screen, the DOM or accessibility tree, history, neighboring elements.
- Candidate generation — Several alternative targets are proposed.
- Scoring — Each candidate receives a confidence score based on explainable signals.
- Technical validation — Uniqueness, visibility, actionability, context and guardrails are checked.
- Decision — High confidence: healing allowed according to policy. Medium confidence: human validation. Low confidence: FAIL.
- Execution — The repaired action runs without changing business data or assertions.
- Assertion — The original business result is verified.
- Audit — Old locator, new locator, score, context, evidence and result are recorded.
7. The confidence score must not be magic
Showing “92% confidence” without explaining that number does not add much safety.
A useful score must be built from observable signals: role match, text proximity, stable attributes, position within the component, similarity with history, candidate uniqueness and consistency with the expected action.
The auto-healing threshold must also depend on risk. Clicking “Close” in an information dialog and confirming a bank transfer do not deserve the same level of autonomy.
8. Three levels of autonomy
| Mode | Confidence / risk | Action | Use |
|---|---|---|---|
| AUTO | High confidence + low-risk action | Repair, execute, trace | Routine regression |
| REVIEW | Ambiguity or medium-to-high risk | Propose and request validation | Critical journey |
| BLOCK | Low confidence or business invariant affected | Do not repair | Security, assertion, critical data |
9. Self-healing and false greens: the critical link
The danger of self-healing is not only clicking the wrong button. It is producing a false green that looks credible.
An overly permissive agent can pick a plausible target, skip a step or adapt an assertion, then declare the scenario successful.
That is why “False positives in automated testing: when a green test lies” and this article are directly connected: a repair must never weaken the business evidence.
A test can be technically healed and still fail functionally. That is a normal, healthy outcome.
10. Self-healing and quality gates
A result that comes from healing should not necessarily be treated exactly like a regular PASS in a quality gate.
A policy can distinguish PASS, PASS_HEALED, REVIEW_HEALED and FAIL. The “healed” status stays visible and can feed a maintenance indicator.
If a critical journey suddenly needs many healings, the cause may be a legitimate redesign of the app, but also test drift or an uncontrolled change. That information is worth tracking.
11. Towards SYMA AGENT
For SYMA AGENT, self-healing must therefore not be a mere XPath replacement engine.
The agent can use the context of the SYMA scenario — action name, description, type, expected texts, locator history, current screen and observed elements — to propose a repair.
On mobile, the accessibility tree, content-desc, resource-id, text and hierarchy provide several signals. On the Web, role, text, label, test-id, attributes and DOM context can be combined. Vision can become a complementary signal when structure is not enough, but it must not, on its own, redefine the intent.
Every healing must leave a trace: why the old locator failed, which candidate was chosen, with what score, which validations were performed and whether the change should then be accepted as the new reference.
This architecture makes it possible to aim for autonomy without sacrificing trust.
SYMA AGENT positioning — The goal is not AI that makes tests pass. It is AI that preserves test intent while adapting safely to technical change.
12. Metrics to track
- Share of scenarios that require healing.
- Share of automatic healings versus healings submitted for validation.
- Human acceptance rate of proposals.
- Business failure rate after healing.
- Number of repeated healings on the same element.
- Distribution of confidence scores.
- Maintenance time saved.
- Rollback rate of repaired locators.
Conclusion
Self-healing is an important evolution of automation, provided autonomy is not confused with permissiveness. AI can help absorb technical changes in the interface, improve locators and reduce maintenance. But it must work within a strict boundary: business intent, critical data, security rules and assertions remain the invariants of the test.
Key takeaway — Repairing how the test reaches its goal: yes. Repairing the goal so the test passes: no.
Want to reduce test maintenance without losing trust in the verdict? Request a SYMA ROBOT demo.
Sources
Documentation consulted on November 1, 2026. The guardrails and governance proposed here are a recommended architecture for SYMA AGENT; they are not presented as requirements of the frameworks cited.
- Playwright — Locators, Auto-waiting (actionability), Assertions and Best Practices
- Selenium — Test Practices, Tips on working with locators and Locator strategies