Prompt
flaky ui tests selector self healing
Latest observation
Oct 26, 2026
OpenAI APIWeb search: off
“Selector self-healing” in flaky UI tests usually means the test tool can recover when a UI element’s locator changes by automatically finding the most likely replacement element.
Why UI tests get flaky
Common causes:
- IDs/classes change between builds
- Elements move in the DOM
- Animations or loading states delay visibility
- Duplicate similar elements make selectors ambiguous
- Responsive layouts change the structure
What self-healing does
If a selector like:
#login-button
fails, the framework may try alternatives such as:
- similar text:
Login - nearby attributes
- DOM structure similarity
- prior successful locator patterns
- visual or accessibility-based matches
Then it may:
- pick the best match,
- continue the test,
- log that healing happened.
Pros
- Reduces maintenance
- Helps keep CI pipelines green
- Useful when UI changes frequently
Cons
- Can hide real regressions
- May click the wrong element if similarity is poor
- Can make failures less deterministic
- Risky for critical flows if used blindly
Best practices
- Prefer stable selectors:
data-testid- accessibility labels
- semantic roles
- Avoid brittle selectors:
- long CSS chains
- dynamic classes
- index-based XPath
- Use self-healing as a fallback, not the primary strategy
- Review healed locator logs regularly
- Add assertions to ensure the correct UI state after healing
Tools that offer some form of self-healing
Depending on your stack:
- Testim
- Mabl
- Functionize
- Healenium
- AI features in some commercial testing platforms
Practical recommendation
A good approach is:
- build tests on stable selectors,
- enable self-healing only for secondary recovery,
- monitor healed events,
- fail tests if healing becomes frequent.
If you want, I can also show:
- an example implementation in Selenium/Cypress/Playwright,
- how to build your own selector-healing logic,
- or a comparison of self-healing tools.