Self-Healing Tests: Never Fix a Broken Selector Again
You've been there: a designer tweaks a button's class name, and suddenly 15 tests fail. The app works perfectly — the tests are just broken. This is selector drift, and it's the silent killer of test suites.
The Selector Drift Problem
Every E2E test relies on selectors to find elements on the page. When those selectors change — even slightly — tests break. Common causes:
The result? Teams spend hours every sprint fixing tests that aren't actually testing anything new. They're just chasing selector changes.
How Self-Healing Works
Self-healing tests detect when a selector breaks and automatically find the correct replacement. Here's the process:
Before and After
Before (broken test):
// This selector breaks when the button class changes
await page.click('.btn-primary.submit-form');
After (healed test):
// Self-healing picks a more resilient selector
await page.getByRole('button', { name: 'Submit' });
The healed version uses Playwright's recommended locator strategy — role-based selectors that are resistant to CSS changes.
Why Version History Matters
Every heal creates a new version of the test. This gives you:
Reducing Maintenance by 70%
Teams using self-healing report dramatic drops in test maintenance time. Instead of manually hunting for broken selectors, the AI does it automatically. Your test suite stays green without constant human intervention.
Setting It Up in Testoro
In Testoro, self-healing is built in. When a test run fails, you'll see a "Heal" button on the test detail page. One click triggers the AI to analyze the failure and generate a fixed version. For Pro plan users, healing happens automatically — no manual intervention needed.
Stop fighting selector drift. Let your tests heal themselves.