Use Anthropic's Computer use API inside playwright tests.
import { test } from "@playwright/test";
import { ai } from "tests-ai";
test("click on counter button", async ({ page }) => {
await page.goto("/");
await ai("click on the counter button and verify that the count goes up", {
page,
test,
});
});
npm install --save-dev tests-ai
You'll need to set your Anthropic API key as an environment variable:
export ANTHROPIC_API_KEY=your-api-key
Or add it to your .env
file:
ANTHROPIC_API_KEY=your-api-key
The ai
function accepts two parameters:
- A string describing the test action to perform in natural language.
- An options object with:
-
page
: Playwright Page object -
test
: Playwright Test object
-