AI Analysis
Claude AI analyzes failures using screenshots, DOM, and error context
Fixwright is an AI-powered service that automatically detects and fixes broken Playwright tests using Claude AI. It works seamlessly with Stepwright failure cases.
Browser automation tests break frequently. Selectors change, page layouts evolve, and timing issues occur. Fixwright automates the maintenance:
AI Analysis
Claude AI analyzes failures using screenshots, DOM, and error context
Automatic Fixes
Proposes and applies code fixes automatically
Validation
Re-runs tests to validate fixes actually work
PR Creation
Creates pull requests with detailed explanations
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐│ Stepwright │────▶│ Fixwright │────▶│ Pull Request ││ Failure Case │ │ AI Analysis │ │ with Fix │└─────────────────┘ └─────────────────┘ └─────────────────┘ │ │ │ ▼ ▼ ▼ Screenshots Claude AI Validated DOM Snapshot Agent SDK Working Fix Console Logsimport { FixWright } from '@korvol/fixwright';
const fixwright = new FixWright({ ai: { apiKey: process.env.ANTHROPIC_API_KEY!, model: 'claude-sonnet-4-20250514', // Optional }, git: { baseBranch: 'main', fixBranchPrefix: 'fix/stepwright-', }, github: { token: process.env.GITHUB_TOKEN!, owner: 'your-org', repo: 'your-repo', },});
// Watch a directory for failure casesfixwright.useFileSource('./failure-cases');
// Listen to eventsfixwright.on('attempt:success', (attempt) => { console.log('Fix successful!', attempt.proposedFix);});
fixwright.on('pr:created', (prUrl) => { console.log('PR created:', prUrl);});
// Start processing failuresawait fixwright.start();Fixwright uses the Claude Agent SDK for autonomous code analysis and fixing:
Process failures from different sources:
// File-based (for development)fixwright.useFileSource('./failure-cases');
// Database (for production)fixwright.useSource(new DatabaseFailureSource({ connectionString: process.env.DATABASE_URL,}));
// Custom sourcesfixwright.useSource(myCustomSource);Multiple fix attempts with learning:
{ fixing: { maxAttempts: 3, // Try up to 3 different fixes maxRetriesPerAttempt: 2, // Retry validation 2 times cooldownMs: 1000, // Wait between attempts }}Subscribe to detailed events:
// Attempt lifecyclefixwright.on('attempt:start', (attempt) => ...);fixwright.on('attempt:analyzing', (attempt) => ...);fixwright.on('attempt:fixing', (attempt) => ...);fixwright.on('attempt:validating', (attempt) => ...);fixwright.on('attempt:success', (attempt) => ...);fixwright.on('attempt:failed', (attempt) => ...);
// Agent activityfixwright.on('agent:thinking', (text) => ...);fixwright.on('agent:tool_use', (tool, input) => ...);fixwright.on('agent:edit', (editInfo) => ...);
// Resultsfixwright.on('pr:created', (prUrl) => ...);fixwright.on('failure:completed', (summary) => ...);┌─────────────────────────────────────────────────────────────────┐│ FixWright │├─────────────────────────────────────────────────────────────────┤│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐ ││ │FailureSource │ │ FixingLoop │ │ EventEmitter │ ││ └──────────────┘ └──────────────┘ └──────────────────────┘ │├─────────────────────────────────────────────────────────────────┤│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐ ││ │ AgentFixer │ │ GitManager │ │ PRCreator │ ││ └──────────────┘ └──────────────┘ └──────────────────────┘ │├─────────────────────────────────────────────────────────────────┤│ Claude Agent SDK ││ (Read, Edit, Bash, Grep, Glob tools) │└─────────────────────────────────────────────────────────────────┘interface FixWrightConfig { // Required: Claude AI configuration ai: { apiKey: string; model?: string; // Default: 'claude-sonnet-4-20250514' };
// Git branch configuration git?: { baseBranch: string; fixBranchPrefix: string; };
// GitHub for PR creation github?: { token: string; owner: string; repo: string; };
// Validation settings validation?: { stepwrightPath: string; timeout: number; };
// Retry settings fixing?: { maxAttempts: number; maxRetriesPerAttempt: number; };}