Self-Healing
The Problem
UI tests are fragile. A developer renames a CSS class, restructures a component, or updates a button, and selectors like #login-btn or .submit-button stop matching. Traditional test frameworks fail immediately, requiring manual updates every time the UI changes.
How Self-Healing Works
When a test step fails because a selector no longer matches, FastTest Agent doesn’t give up. It runs a 5-strategy healing cascade — trying increasingly creative ways to find the element. The first strategy that works wins.
-
Stored Pattern Lookup (instant)
FastTest Agent checks if this exact failure has been healed before — by you or anyone on your team. If a fix already exists with high confidence, it’s reused instantly. No scanning needed.
-
data-testid — 98% confidence
Looks for
data-testid,data-test, ordata-test-idattributes that match the original selector’s name. These attributes are explicitly for testing, so they’re very reliable. -
ARIA labels — 95% confidence
Searches for
aria-labelattributes matching the element name. ARIA labels are semantic and tend to survive UI refactors. -
Text content — 90% confidence
Uses the visible text on the element — like “Login”, “Submit”, “Add to Cart” — to find a match.
-
Structural — 85% confidence
Looks at the element’s tag name,
nameattribute, and fragments ofidorclassattributes to locate it by structure. -
AI Assistant Reasoning (fallback)
If all local strategies fail, FastTest Agent returns a page snapshot and prompt to your AI assistant. The assistant reasons about the page structure and suggests alternative selectors using its own understanding of the DOM — no separate cloud LLM call needed.
Org-Wide Pattern Sharing
This is where self-healing gets powerful. Every successful heal is stored in your organization’s pattern database. That means:
- One fix benefits everyone. When a teammate’s test run heals a broken selector, your tests benefit from that fix automatically on the next run.
- Patterns compound over time. After a few weeks, most selector failures are resolved instantly from stored patterns — no cascade needed.
- Instant reuse. Stored patterns resolve in milliseconds, with no browser scanning or AI calls.
What Gets Healed (and What Doesn’t)
FastTest Agent is smart about what it tries to heal:
- Element not found — The selector matched nothing. Healable.
- Timeout — The element didn’t appear in time. Healable.
- Assertion failed — The element was found but the assertion (text, URL, count) failed. If the test was passing consistently before, this is flagged as a real bug and healing is skipped.
- Navigation failed — The page didn’t load. Not healable.
Confidence Levels
Each healing strategy has a confidence score that reflects how reliable the fix is:
| Strategy | Confidence | Why |
|---|---|---|
| Stored patterns | Instant | Previously healed — no scanning needed |
| data-testid | 98% | Explicitly for testing — very stable |
| ARIA labels | 95% | Semantic and rarely changed |
| Text content | 90% | Visible text can change with copy updates |
| Structural | 85% | Page structure may shift with layout changes |
| AI fallback | — | Your AI assistant reasons about the page snapshot |
Stored patterns are only auto-applied when confidence is 80% or higher. Below that, they’re treated as suggestions.
Viewing Your Healing History
From your AI assistant:
Ask: “Show my healing history” — FastTest Agent calls the heal tool with show_history: true and shows you:
Healing StatisticsTotal healed: 47Patterns stored: 12Avg confidence: 92%
Strategy breakdown: data_testid: 23 heals aria: 11 heals text: 8 heals structural: 5 healsFrom the Dashboard:
Open the Healing section to browse all stored patterns, see which selectors have been healed, and review the strategies used.
Tips for Better Healing
- Add
data-testidattributes to key interactive elements in your app. This gives the highest-confidence healing path. - Use semantic HTML —
<button>,<a>,<input>with properaria-labelandnameattributes. - Don’t fight it — let FastTest Agent heal selectors naturally. The pattern database gets smarter with every run.