Imported from harikch2209/AITestAgent (
skills/self-heal/SKILL.md). Install upstream withnpx skills add harikch2209/AITestAgent --skill self-heal. Copyright stays with the author.
Self-Heal
Automatically fixes broken locators at runtime when elements change on the page.
When to Use
- Tests are failing because page elements have changed
- Locator selectors are stale or broken
- User says "fix my broken tests" or "update locators"
How It Works
When a locator fails during test execution, the self-healer:
- Try alternative strategies: If CSS selector fails, try getByRole, getByPlaceholder, getByLabel based on the element name
- Fuzzy text match: Search for elements with similar visible text
- DOM scan: Scan the page for elements matching the expected type, score candidates by attribute similarity
- Auto-update: If healed, update the locator JSON file for future runs
Configuration
Self-healing is enabled by default. Disable with:
npm start -- --file tests/login.md --no-self-heal
Report Integration
Healed locators are marked in the HTML report with the original and new locator strategies, along with a confidence score.
[ PASS ] Click on "Login Button" (234ms) [HEALED]
Self-healed: css:"#old-login-btn" → getByRole:"button" (80% confidence)