Skip to content

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.

  1. 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.

  2. data-testid — 98% confidence

    Looks for data-testid, data-test, or data-test-id attributes that match the original selector’s name. These attributes are explicitly for testing, so they’re very reliable.

  3. ARIA labels — 95% confidence

    Searches for aria-label attributes matching the element name. ARIA labels are semantic and tend to survive UI refactors.

  4. Text content — 90% confidence

    Uses the visible text on the element — like “Login”, “Submit”, “Add to Cart” — to find a match.

  5. Structural — 85% confidence

    Looks at the element’s tag name, name attribute, and fragments of id or class attributes to locate it by structure.

  6. 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:

StrategyConfidenceWhy
Stored patternsInstantPreviously healed — no scanning needed
data-testid98%Explicitly for testing — very stable
ARIA labels95%Semantic and rarely changed
Text content90%Visible text can change with copy updates
Structural85%Page structure may shift with layout changes
AI fallbackYour 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 Statistics
Total healed: 47
Patterns stored: 12
Avg confidence: 92%
Strategy breakdown:
data_testid: 23 heals
aria: 11 heals
text: 8 heals
structural: 5 heals

From 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

  1. Add data-testid attributes to key interactive elements in your app. This gives the highest-confidence healing path.
  2. Use semantic HTML<button>, <a>, <input> with proper aria-label and name attributes.
  3. Don’t fight it — let FastTest Agent heal selectors naturally. The pattern database gets smarter with every run.