Quick Start
This guide takes an existing Playwright script and makes it self-healing. Prerequisite: the healing stack is running.
1. Change the import
import { chromium } from 'playwright';import { chromium } from '@autowright/browser';That’s the only structural change. Everything your script does with browser,
page, and locators stays plain Playwright.
2. Tell Autowright about your script
Add an autowright block to launch():
import { chromium } from '@autowright/browser';
const browser = await chromium.launch({ headless: true, autowright: { scriptId: 'portal-scraper', // stable ID for this script serviceUrl: 'http://localhost:4400', // where the service runs repoUrl: 'https://github.com/your-org/scrapers', // repo the fixer should clone scriptPath: 'src/scraper.ts', // this file, repo-relative },});
// Normal Playwright from here. All capture is invisible.const page = await browser.newPage();await page.goto('https://portal.example.com');await page.locator('#login-btn').click();await browser.close();repoUrl and scriptPath are what let the fixer find the code to fix — point
them at the repository and file where this script actually lives.
3. Run it
npx tsx scraper.tsOn success, nothing is different — your script runs and exits as usual.
4. When it breaks
Say the site renames #login-btn. Your script still fails with the normal
Playwright TimeoutError — Autowright never swallows errors. But behind
the scenes:
- The failure is classified (
SELECTOR_NOT_FOUND) and the evidence — screenshots, DOM snapshot, network log, console log, action log — is bundled and uploaded to artifact storage. - The service dedupes the incident by error hash and queues a fix job.
- The fixer clones your repo, and a Claude agent reasons over the captured DOM to find what replaced your selector.
- If the agent is confident, you get a pull request (and a Slack message with the real cost — typically well under a dollar). If not, you get a needs-attention notification with the diagnosis and evidence bundle.
You review the PR against the live site and merge. The script heals.
Next steps
- How It Works — the full capture → fix data flow
- Configuration — every
autowrightconfig field - Fix Lifecycle — dedup, confidence gate, outcomes