Skip to content

API Reference

Complete API documentation for both Autowright packages.

Packages

@autowright/stepwright

Fluent API for building structured browser automation scripts with Playwright.

  • Chain-based script building
  • Checkpoints with retry boundaries
  • Artifact capture (screenshots, traces, video)
  • Multiple reporter support

@autowright/fixwright

AI-powered service that automatically fixes failing Stepwright scripts using Claude.

  • Claude Agent SDK integration
  • Automatic fix validation
  • Git integration and PR creation
  • Event-driven architecture

Stepwright API

The runner framework for creating and executing automation scripts.

Quick Example

import { Stepwright, ConsoleReporter } from '@autowright/stepwright';
const script = Stepwright.create<{ token?: string }>('Login')
.config({ headless: true, screenshotOnFailure: true })
.reporter(new ConsoleReporter())
.checkpoint('Authentication')
.step('Navigate', async (ctx) => {
await ctx.page.goto('https://example.com/login');
})
.step('Login', async (ctx) => {
await ctx.page.fill('#email', 'user@example.com');
await ctx.page.click('#submit');
})
.endCheckpoint();
await script.run();

Fixwright API

The AI-powered fixer service for automatic script maintenance.

Quick Example

import { FixingLoop, FileFailureSource } from '@autowright/fixwright';
const source = new FileFailureSource('./failure-cases');
const fixingLoop = new FixingLoop({
ai: { apiKey: process.env.ANTHROPIC_API_KEY! },
git: { baseBranch: 'main', fixBranchPrefix: 'fix/stepwright-' },
github: { token: process.env.GITHUB_TOKEN!, owner: 'org', repo: 'repo' },
fixing: { maxAttempts: 3 },
workDir: process.cwd(),
}, source);
fixingLoop.on('attempt:success', (attempt) => {
console.log('Fixed:', attempt.analysis?.explanation);
});
fixingLoop.on('pr:created', (url) => {
console.log('PR:', url);
});
await fixingLoop.processFailure(failureCase);

Shared Types

Both packages share common types from @autowright/shared:

import type { FailureCase, StepResult } from '@autowright/shared';

Key shared types include:

  • FailureCase - Failure information passed from Stepwright to Fixwright
  • StepResult - Result of a step execution
  • Event types for inter-package communication

See Also