GuideAutohealing

Autohealing Failing Tests

AutoReg’s autoheal loop finds the root cause of a failing test and regenerates it against the live app — no manual selector hunting required.

The autoheal workflow

Run test(s)
    ↓ failure detected
test_run_analyzer
    Parses execution.log and failure artifacts
    Identifies: selector not found / assertion failed / navigation error / timeout
    Outputs root cause + suggested fix per scenario

test_regenerator
    For selector failures: re-navigates the live page, captures DOM snapshot
    Generates corrected E2ESpecFile with updated selectors

apply_scenario_fix
    Writes corrected scenario-NNN.json to disk
    Updates .ar manifest

Re-run test to verify fix

Triggering autoheal

From the chat panel

After a failed run, type:

"Fix the failing tests"
"Analyze and heal scenario-004"
"Why is scenario-007 failing?"

The agent runs the full loop: analyze → regenerate → apply.

Targeted healing

"Heal scenario-003 — the login button selector changed"
"The email field on /signup now has aria-label 'Work email', update scenario-002"

For targeted cases, the agent skips re-navigation and applies the fix directly.

What test_run_analyzer reports

For each failing scenario:

FieldDescription
scenarioIdWhich scenario failed
failureTypeselector / assertion / navigation / timeout
failedStepThe exact step that failed
suggestedFixWhat to change
confidencehigh / medium / low

High-confidence fixes (e.g. element moved but still exists with different ARIA label) are applied automatically. Low-confidence cases are shown in chat for your review before applying.

What test_regenerator does

For selector failures:

  1. Opens a headed or headless browser
  2. Navigates to the page where the failure occurred
  3. Captures a fresh DOM snapshot
  4. Asks the LLM to regenerate the failing steps using the new snapshot
  5. Returns an updated E2ESpecFile

For assertion failures:

  • Inspects current page state vs. expected state
  • Updates value or assertionType to match the app’s current behavior

For navigation / timeout failures:

  • Checks if the URL changed (redirects, route renames)
  • Updates navigate steps accordingly

Reviewing a fix before applying

If the agent proposes a fix and asks for confirmation:

Agent: "I found that [aria-label='Email address'] is now [aria-label='Work email'].
       Updated scenario-002 step 2. Apply this fix?"

You: "yes"   ← applies the fix
You: "no, the label is 'Company email'"   ← agent uses your correction

Bulk healing after a deployment

After a large UI change, run the full suite and then:

"Heal all failing tests"

The agent batches test_run_analyzer across all failures, then calls test_regenerator + apply_scenario_fix for each one. Progress is shown in the chat thread.

When autoheal cannot fix a test

Some failures require human judgment:

SituationWhat to do
Feature was removed from the appDelete the scenario: "Delete scenario-011"
Business logic changedUpdate autoreg.md and regenerate: "Regenerate scenario-005"
Multi-step flow redesignedDescribe the new flow in chat; the agent regenerates from scratch
Flaky test (timing issue)Add a wait step or increase timeout: "Add a 2s wait before step 4 in scenario-008"

Regenerating a scenario from scratch

"Regenerate scenario-006 from scratch using the current app"

This triggers generate_single_scenario, which re-navigates the live page and generates a fresh test — discarding the old steps entirely.

Tips

  • Run autoheal after every deploy — paste the run output in chat or just type “heal failing tests” after each run.
  • Keep autoreg.md up to date — if features change, update your spec so regenerated tests reflect the new behavior.
  • Check confidence: low suggestions — the agent flags uncertain fixes; review these before applying.
  • Videos help diagnosis — enable video recording in settings so you can see exactly what happened before the failure.