Self-healing test automation lets a test recover when it can't find an element with its stored locator. This guide covers how it works, what it can't fix, how to implement it, and how self-healing works in Katalon Studio.
Automated UI tests often fail for a dull reason rather than a real bug: a locator stops matching. A developer renames a class, a layout shifts, or an ID becomes dynamic, and dozens of tests fail with "element not found" even though the feature still works.
Self-healing test automation targets that problem. When a test can't find an element with its main locator, it tries other ways to identify the same element, continues the run if it finds a match, and reports what it changed so you can review it.
This guide explains how self-healing works, what it can and can't fix, how to build it into your test framework, and how self-healing works in Katalon Studio.
What is self-healing test automation?
Self-healing test automation is the ability of an automated test to recover when it can't find a UI element with its stored locator, by finding the same element another way during the run instead of failing. It's also called auto-healing. Tests that recover this way are called self-healing tests, and the locators involved are often called self-healing locators.
It addresses one specific cause of failure: locator breakage after UI changes. It doesn't fix tests that fail because the app's behavior changed, because the test logic is wrong, or because of timing and test data problems. If you're new to the topic, start with what is automation testing.
Why automated UI tests break
Many UI test failures that aren't real bugs come from the way tests find elements:
- Changed or dynamic attributes: IDs and class names get renamed in a refactor or regenerated by front-end frameworks on every build.
- DOM structure changes: a new wrapper element or reordered content breaks long, absolute XPath and deeply nested CSS selectors.
- Changed text: copy updates break locators that match on button or link text.
- Different environments: browsers, screen sizes, and localized builds can expose a different DOM for the same screen.
These failures, such as a NoSuchElementException, say nothing about product quality. They add noise, slow down releases, and teach teams to ignore red builds. For the wider problem, see flaky tests in test automation.
How self-healing works
Most self-healing test automation tools follow the same basic loop:
- Capture several identifiers per element. When a test object is recorded or created, the tool stores more than one way to find it: ID, name, CSS selector, XPath variants, other attributes, text, and sometimes a screenshot.
- Detect the failure. During the run, the primary locator returns no element.
- Try the alternatives. The tool works through its fallback options in priority order, from other stored locators to attribute matching, image matching, or an AI model that analyzes the page.
- Continue or fail. If it finds a match, the step runs and the test continues. If not, the step fails as it normally would.
- Report the heal. The tool logs the broken locator, the locator that worked, and how it found the element, so someone can approve the fix or reject it.
The main healing techniques trade speed for reach:
Technique | How it finds the element | Best for | Watch out for |
|---|---|---|---|
Fallback locators | Tries the next stored locator (CSS, XPath, attributes) | Elements with several stable identifiers | Only as good as the alternatives you stored |
Attribute matching | Matches the element's remaining known attributes | Renamed IDs or classes | Can match a similar but wrong element |
Image matching | Compares a stored screenshot of the element | DOM changes where the element looks the same | Sensitive to styling, theme, and resolution changes |
AI-based healing | A model analyzes the page source, accessibility tree, or screenshots and proposes a locator | Bigger changes where every stored locator fails | Slower, can add cost, and still needs review |
Benefits of self-healing test automation
- Fewer false failures: locator changes stop failing whole suites, so a red build is more likely to mean a real bug.
- Less maintenance: teams spend less time updating selectors after every UI change.
- More reliable CI and nightly runs: one renamed class no longer stops a pipeline.
- A record of what changed: heal reports show which locators are fragile, so you can fix them deliberately.
Limits and risks of self-healing
Self-healing is useful, but it isn't free of risk:
- It can heal to the wrong element. A similar button or field can match, and the test passes when it shouldn't. Review every heal.
- It can hide real changes. If an element disappeared because of a bug, healing a verification step masks it. Keep healing off for assertions and wait steps.
- It doesn't fix timing, data, or logic failures. Those need explicit waits, controlled test data, and test fixes.
- It doesn't replace good locators. A suite that heals on every run has a locator problem, not a healing feature.
- AI healing has a cost. Model-based healing takes longer per heal and can add usage cost, so use it after cheaper methods fail.
How to implement self-healing test automation
1. Find where your tests break
Review your failure history and tag every failure caused by an element not being found. Start with the flows that break most often, and look for fragile locators: long absolute XPath, deeply nested CSS selectors, and generated IDs.
2. Start with stable locators
Agree on dedicated test attributes (such as data-testid) or stable IDs with your developers, and use them as each element's primary locator. Self-healing is the fallback, not the plan.
3. Store more than one locator per element
Give each element a primary locator and ordered fallbacks, for example a test ID or CSS selector first, then a relative XPath, then other attributes or text. This redundancy is what most healing methods rely on.
4. Turn on healing and set its scope
Enable self-healing at the project level, choose the healing methods and their order, and exclude steps where a heal could hide a real problem, such as assertions and waits.
5. Review every heal and update the source
After each run, approve or reject the proposed locators. Approved locators become the new default, so the same heal doesn't have to run again. Track how often each page heals: frequent heals on one page mean it needs better locators.
6. Add AI-based healing for harder cases
Use AI-based or image-based healing for elements where every stored locator fails. Weigh the extra time and cost, and review AI-proposed locators the same way as any other heal. For tools that offer AI-based healing, see best AI testing tools.
For broader practices that keep suites maintainable, see test automation best practices.
Self-healing in Katalon Studio
Katalon Studio has self-healing for Web UI and mobile tests. It combines classic and AI self-healing, and every heal is listed for review.
- Classic self-healing: when an object's default locator fails, Studio tries the other selection methods in the priority order you set. For web objects these are XPath, Attributes, CSS, Image, and Smart Locator. You enable it separately for Web UI and Mobile under Project > Settings > Self-Healing, or from the Self-Healing icon in the main navigation panel.
- Excluded keywords: Verify and Wait For keywords are excluded by default, because healing them can cause false positives. You can add your own keywords to the exclusion list.
- AI self-healing: if classic self-healing can't recover an object, Studio can use a large language model to analyze the page source, the accessibility tree (web), and screenshots, and suggest a new locator. It needs an active license, Execution Viewer turned on (Project > Settings > Execution), and AI capabilities turned on for the project (in Studio 11.7 and later, under Project > Settings > AI Capabilities). Adding more inputs can improve accuracy but takes more time and cost.
- Self-healing Insights: after a run, this tab lists each healed object with its broken locator, proposed locator, the method that recovered it, and a screenshot to check. Approve a proposal to save it as the new default, or discard it.
- When nothing heals: if neither method recovers the object, the step's failure handling setting decides whether the test stops or continues.
For setup details, see Katalon's self-healing documentation. Before self-healing was built into Studio, it was available through the Auto-healing Smart XPath plugin. For that history and XPath tips, see smart XPath generator.
Conclusion
Self-healing test automation reduces a common source of noise in UI testing: tests that fail only because a locator changed. It works best as a safety net on top of stable locators, with healing kept away from assertions and every heal reviewed before it becomes the new default. Used that way, it cuts maintenance while keeping the risk of hidden bugs low. To see where AI fits across the rest of testing, see AI in quality assurance.
Frequently asked questions
Self-healing test automation lets an automated test recover when it can't find a UI element with its stored locator. The test finds the same element another way during the run, continues if it finds a match, and reports the change for review.
Many non-bug failures come from locators: IDs and classes get renamed or generated dynamically, DOM structure changes break long XPath and nested CSS selectors, and text changes break text-based locators. The feature still works, but the test can't find the element.
When the primary locator finds nothing, the tool tries other ways to identify the element: stored fallback locators, attribute matching, image matching, or an AI model that analyzes the page. If one finds a match, the step runs and the tool logs the proposed locator for you to approve or reject.
Find where tests break, use stable test IDs as primary locators, store several ordered fallback locators per element, turn on healing with assertions and waits excluded, review every heal after each run, and add AI-based healing only for cases where stored locators all fail.
When stored locators all fail, an AI model analyzes signals such as the page source, the accessibility tree, and screenshots, and proposes a new locator for the element. It reaches further than fallback locators, but it's slower, can add cost, and its proposals still need review.
Self-healing locators are element locators backed by fallbacks. If the primary locator stops matching, the test tries the stored alternatives, or AI, to find the same element, and logs the locator that worked so it can become the new default.
Yes, if it's used carelessly. A heal can match the wrong element and let a test pass, and healing a verification step can mask an element that really is missing. Exclude assertions and waits from healing, and review every heal.
Only flakiness caused by changing locators. Tests that fail because of timing, test data, environment problems, or order dependence need explicit waits, controlled data, and independent tests.
Katalon Studio has classic self-healing for Web UI and mobile tests, which tries other selection methods in your priority order (for web objects: XPath, Attributes, CSS, Image, and Smart Locator), and AI self-healing, which uses a large language model when classic healing fails. Healed objects appear in the Self-healing Insights tab, where you approve or discard each proposed locator.

Test everything. Ship with confidence.
From generating test cases to spotting failures, Katalon's AI works across your entire pipeline, automatically.

