Open source · MIT license

Add AI steps to Playwright tests with ai-wright

ai-wright is a free, open-source library from TestChimp that adds ai.act, ai.verify and ai.extract to any Playwright test. Use it for the steps where selectors are brittle or the UI genuinely varies, and keep the rest of the test as plain Playwright.

What it does

  • ai.act performs one or more UI actions to reach an objective, clearing blockers such as modals first.
  • ai.verify is a vision-based assertion that fails the step when confidence drops below a threshold (70% by default).
  • ai.extract pulls structured data from the page as strings, numbers or lists.
  • Vision first: screenshots are annotated with Set-of-Marks overlays and paired with a DOM element map.
  • Bring your own OpenAI, Gemini or Claude key, or use a TestChimp key.

Install and run

Install
npm install ai-wright
Use it in a test
import { test } from '@playwright/test';
import { ai } from 'ai-wright';

test('send message', async ({ page }) => {
  await page.goto('https://your-app.example');
  await ai.act('Log in as alice@example.com with password TestPass123', { page, test });
  await ai.act('Open the Messages tab and send "Hello"', { page, test });
  await ai.verify('The message input is empty afterwards', { page, test });
});

Set OPENAI_API_KEY, GEMINI_API_KEY or CLAUDE_API_KEY before running your tests. See the README for model settings and timeouts.

More open-source tools

Run AI steps on every pull request

TestChimp SmartTests are standard Playwright tests that use the same ai.act and ai.verify steps, linked to your test plans and run on every pull request.

Start your free trial

14-day free trial. No credit card required.