# Build a testing agent with Claude Code and Playwright

> One folder, one command: Claude explores a site, plans its tests, runs them with Playwright, and delivers a report backed by proof. 15 minutes to set up.

Source: https://qanary.dev/en/blog/testing-agent-claude-code-playwright  
Product: Qanary, no-code automated testing for e-commerce  
Site index for AI assistants: https://qanary.dev/en/llms.txt

[Blog](https://qanary.dev/en/blog) · Guide

One folder, one command: Claude explores a site, plans its tests, runs them with Playwright, and delivers a report backed by proof. 15 minutes to set up.

[Antoine Bouchet](https://qanary.dev/en/about#antoine), CEO of Qanary, June 2, 2026 · 7 min read

*How I gave Claude a spec so it would write **and** run its own E2E test plan, in a real browser, with a visual report at the end.*

## The idea in two sentences

You describe the site to test in a plain text file. Claude explores it on its own, **plans** a list of tests, **runs** them in a real browser through Playwright, then produces a **visual report** with an honest verdict for each one: 🟢 OK, 🔴 bug, or 🟠 “to check.”

The key words are **autonomous but auditable**: Claude does the work, but every verdict is backed by an observation and a screenshot. No black magic.

By the end of this tutorial, you’ll have a folder that runs *plan → test → report* in one command. Allow 15 minutes to set it up.

## What you need

- [Claude Code](https://claude.com/claude-code), installed and signed in: it orchestrates everything.
- [The **qa-agent-shared** folder, to download](https://drive.google.com/file/d/19bgmw2IHaZmB2ocKoc1PJg5iwlMMDcd7/view?usp=sharing) (the commands and scripts, ready to use). You can simply add it to Claude Code’s root folder.
- Ask Claude to open the **qa-agent-shared** folder (and approve its requests).

You **don’t need to know how to code**, or to master Node.js or Playwright. Node.js runs behind the scenes, and Claude Code drives the browser for you. In practice: you download the folder, open Claude Code in it, and talk to it.

The folder was built by our French team, so its files and commands have French names. You can talk to Claude in English.

## Step 1: what’s in the folder

You have nothing to build: the qa-agent folder is already organized around Claude Code **commands** (Markdown files) and two scripts. Here’s what it contains:

qa-agent/ ├── .claude # /preparer, /cible, /plan, /test, /rapport, /agent-qa ├── cible.md # WHAT WE WANT TO TEST (the only file to fill in) ├── lancer.mjs # runs plan → test → report ├── construire-rapport.mjs # generates the HTML report └── captures/ # screenshots (proof)

The guiding principle: **everything is in human-readable Markdown**. No JSON in the working files. Anyone can review the plan and the results without knowing how to code.

Claude Code handles the browser connection. It detects what it needs on its own and simply asks you, the first time, to allow the “Playwright server.” You accept, and you’re done. Same for Node.js.

## Step 2: say what you want to test

You don’t fill in any file by hand. You start the agent, for example by typing “**I want to run the QA agent** ” (or the /agent-qa command), and **Claude Code takes care of everything**.

It first runs all the technical checks it needs to make sure it has everything, then asks you a few **questions**:

1. Which **site** do you want to test? (the URL)
2. What **expectations or specs**? (or “none” for a “blind” test)
3. How many **tests** do you want? (a rough number)

From your answers, Claude fills in the cible.md file **itself**: you don’t have to touch it. The result looks like this:

## Site URL https://www.mysite.com/ ## What I want to test No spec: "blind" test. Discover the site and cover the basics. ## Number of tests wanted (rough) ~10 ## Limits to respect - Do NOT actually submit any form (no account, no payment). - Read and browse only: no destructive action.

Two things matter: the **spec** (or “none”) and the **limits**. The limits are sacred: they stop the agent from sending a real contact form or triggering a payment. If you don’t set any, the agent stays in read-and-browse mode by default, without breaking anything.

> ⚠ This project is flexible. If something isn’t done the way you want, or you have specific needs, ask Claude what should change in the project: it will make the adjustments.

## Step 3: planning (/plan)

First phase. Claude reads cible.md, **explores the site in the browser**, and writes a plan in plan-de-test.md. It runs **no** tests here: it observes and plans.

This phase should start automatically; if it doesn’t, ask Claude.

The result: a numbered, readable plan, along the lines of T01 — The home page loads, with a goal, steps, and an expected result.

💡 **Why separate planning and running?** Because the plan is an artifact that a human **reviews and corrects** before the tests run. That’s what makes the system auditable rather than a black box.

## Step 4: running the tests (/test)

Second phase. Claude runs each test of the plan in the browser, takes a **proof screenshot** for each test, and writes an honest verdict in resultats.md.

The three golden rules of this phase:

1. **No verdict without proof**: a factual observation and a screenshot.
2. **No courtesy verdicts**: if it can’t decide (ambiguous page, blocked page, out of scope), it’s 🟠 “to check,” never 🟢.
3. **No bug without a double check**: before reporting a bug, Claude checks that it isn’t a false positive (a lazy-loaded image, an element off screen…).

That 🟠 is the heart of the system’s honesty. A tester who makes up “OK”s is worse than useless. Here, uncertainty is a status in its own right.

## Step 5: the report (/rapport)

Third phase: Claude Code turns resultats.md and the screenshots into a **standalone report** (a single file, screenshots included, that opens offline).

> ⚠ **The most important lesson of the project.** At first, I asked Claude to *generate* the report’s HTML *itself* . Bad idea: encoding more than 20 screenshots in base64 in a single call is too heavy. The phase “failed” silently and left an old report in place. The right approach: **generate the report deterministically, with a Node script**. It hasn’t failed since, and it frees the AI from mechanical tasks where it adds nothing.

The construire-rapport.mjs script reads the Markdown results, encodes the screenshots, and produces a **scoreboard** (🟢/🔴/🟠 counters) plus **one accordion card per test**: a clickable header, a chevron that rotates, bugs open by default. Readers expand what interests them.

The general rule to remember: **have the AI do what takes judgment (exploring, deciding a verdict), and have code do what takes reliability (assembling a file).**

## Step 6: chain it all together (lancer.mjs)

To stop typing anything by hand, you can ask Claude Code to run the whole process (node lancer.mjs).

The script chains the AI phases (plan → test) in non-interactive mode, **then generates the report locally**, adds up the tokens used, and **archives each run’s report** in its own folder:

runs/ ├── mysite_2026-06-01_15-11/rapport.html └── mystore_2026-05-28_09-30/rapport.html

The “subject” (mysite, mystore) is taken automatically from the URL, and the date and time keep a run from overwriting the previous one. That gives you a history per site, over time.

### Bonus: run it every day

Since it’s a single command, you can ask Claude Code to turn it into a scheduled task (cron), for daily monitoring for example.

## The traps you’ll avoid (because I hit them)

- **The report that’s “generated” but stale** → deterministic generation by a script, not by the AI (step 5).
- **Files that overwrite each other** → one runs/<subject>_<date>/ folder per run (step 6).
- **Junk that piles up** (MCP logs, snapshot dumps) → automatic cleanup at the end of each run, and a .gitignore.

## What it changes

With one command, I have a tester that:

- **explores** a site it doesn’t know,
- **plans** relevant coverage,
- **runs** the tests in a real browser,
- and delivers a verdict that is **proven**, not bluffed.

It all stays **local and auditable**: the plan can be reviewed, the verdicts rely on screenshots, and every run is archived. Autonomous, but under control.

*The complete code (commands and scripts) fits in a folder you can download and run in 15 minutes. That’s exactly the spirit of Qanary: serious tests, without the friction.*

## Honestly: when to use it… and when to choose a platform

Let’s be clear about when this agent is the right tool, because that’s what matters most.

### 1. Perfect for exploring, less so for automating the same scenario every day

This agent shines at one thing: **exploration**. Discovering a site, casting a wide net, checking the basics, clearing up doubts: that’s where it’s unbeatable, because it *understands* what it sees and adapts on its own.

For **precise, repeated automation**, on the other hand (replaying **exactly the same regression scenario** every day), a dedicated platform like Qanary is a better fit. You don’t want a test to “think” all over again every morning: you want it to reproduce the scenario identically, quickly, and **deterministically**. An agent that reinterprets the page on every run is great for discovery… and counterproductive when you’re looking for stability.

### 2. The token cost: great once in a while, unsustainable at scale

Making an AI think at every step uses **tokens, a lot of tokens**. For a one-off exploration, it’s well worth it: a few euros for a full audit is hard to beat. But if you want to run **50 tests a day**, every day, the bill quickly gets unreasonable. You’d be paying for intelligence where all you need is **reliable repetition**.

That’s also one of the reasons to use **Qanary**. Our approach: put **AI in the right places** (understanding a page, validating steps, explaining a failure in plain language), but keep a **classic, deterministic test engine** for repeated runs. The result: **much cheaper** and **more relevant** for repetitive regression tests, where pure AI would cost too much and drift.

*The right question isn’t “AI or no AI?” but “AI, where exactly?” Explore with an autonomous agent; automate day to day with a platform like Qanary.*

Want to see Qanary test your site? Book your free 30-minute test run with Julia or Antoine.

**Antoine Bouchet** Ten years in product management, on high-impact sites. He wants to raise the quality of online stores, with a product that does exactly what its users need. [More about Antoine](https://qanary.dev/en/about#antoine)

## Read next

- Talk
  ### [Self-healing: how AI repairs a broken test](https://qanary.dev/en/blog/self-healing-tests-with-ai)
  Self-healing repairs a test when the site changes. Three approaches with AI, from the most guided to the most autonomous, and their limits (ParisTestConf 2026).
  **Antoine Bouchet**, March 30, 2026 · 4 min read
- Talk
  ### [The quality mindset: how to ship flawless WordPress sites](https://qanary.dev/en/blog/quality-mindset-wordpress-sites)
  Define your critical journeys, document them in a spreadsheet, and move from reactive quality to quality you control: our talk at WordCamp Nice 2026.
  **Antoine Bouchet**, February 13, 2026 · 2 min read
- Guide
  ### [How to create an automated test with AI, step by step](https://qanary.dev/en/blog/create-an-automated-test-with-ai)
  AI writes the skeleton, the Playwright recorder supplies the real selectors, and you keep the judgment: a checkout test in about twenty minutes.
  **Antoine Bouchet**, January 26, 2026 · 5 min read

[All articles](https://qanary.dev/en/blog)
