A self-healing decorator for Playwright UI tests — inspired by Healenium. Automatically heals broken selectors using fuzzy matching and maintains fallback history.
- ✅ Self-heals selectors using fuzzy text-matching
- 📖 Tracks fallback usage and selector history
- 🧩 Decorator-based usage via
@Healenium
- 🔁 Automatically updates fallback selectors
- 🧰 Written in TypeScript, ready for npm publishing
npm install healenium-js
import { Healenium } from 'healenium-js';
class MyTests {
page: Page;
constructor(page: Page) {
this.page = page;
}
@Healenium('#non-existent-button')
async clickMissingButton() {
await this.page.click('#non-existent-button');
}
}
npx playwright test
- ✅
fallback-selectors.json
— latest healed selectors - 📚
selector-history.json
— all past fallback selectors
- When a selector fails, the plugin:
- Extracts its text
- Uses Levenshtein distance to find a similar element
- Generates a new selector and stores it
- Re-runs the test using the new selector
import { test as base } from '@playwright/test';
import { Healenium } from 'healenium-js';
class Demo {
page: Page;
constructor(page: Page) {
this.page = page;
}
@Healenium('#broken-selector')
async triggerHealer() {
await this.page.click('#broken-selector');
}
}
base('Healenium demo', async ({ page }) => {
const t = new Demo(page);
await page.goto('https://example.com');
await t.triggerHealer();
});
MIT © [Your Name]