Test-AI — AI-driven Playwright tests¶
In Test-AI, the student describes a test in plain language to an agent. The agent writes a Playwright script, Test-AI checks it, runs it in an isolated browser against the shop, and returns the video, the log, the failure screenshots, the script and a report. A failing test creates an anomaly in the deliverables.
What this page describes
Test-AI 0.24.0, as the shipped code behaves (test-ai/src/routes/runs.js, test-ai/src/services/aiOrchestrator.js,
aiAgenticOrchestrator.js, playwrightRunner.js, test-ai/src/lib/script-validator.js, test-ai/public/js/runner.js).
Sister pages: Watch a test live, Deliverables,
Configure the language model.
The flow¶
flowchart LR
D["Student's request<br/>(conversation)"] --> A["Agent<br/>(language model)"]
A --> P["Proposal:<br/>'run a test'"]
P -->|Confirm| G["Playwright script<br/>written by the model"]
G --> V{"Validator"}
V -->|rejected| G
V -->|accepted| X["Execution<br/>perfshop-playwright"]
X --> R["Results: log, video,<br/>screenshots, script, report"]
X -->|failure and iterations left| G
R -->|final failure| N["Anomaly<br/>in the deliverables"]
Before you start¶
- Open Test-AI: from the platform's welcome page, or at the host address, port 3006 —
http://<host IP address>:3006in a classroom, the public address of Test-AI (domain name) on the Internet. - The account: a PerfShop admin account holding the "Test-AI" right (the trainer ticks it in the Chaos console, "Admin account management" page), or the superadmin. Student accounts do not have this right by default. Without an active PerfShop licence, sign-in is refused.
- The language model: a provider saved through "Configure LLM" (see Configure the language model). Without it, no test starts.
- The target: the platform's shop. The installer (
./build.sh) writes its address intoPERFSHOP_FRONTEND_INTERNAL(host address and shop port); on the NAS, the NAS layer puts the shop's public address there. To test another site, setTEST_AI_TARGET_URLin.env.
The Test-AI screen has three columns: on the left the agent's brain (context, personas, skills, documents), in the middle the conversations (up to 5, each with its Study, Exploration, Run and Editor sub-tabs), on the right the deliverables.
Run a test¶
- In the conversation (Study sub-tab), describe the test: "Open the products page, add the first item to the cart and check that the cart shows 1 item." Quote a deliverable by its code when useful — "write the test of requirement EXG-004": its content is attached to the context.
- The agent answers, and proposes to run the test: "The AI proposes to run a Playwright test:". Nothing starts without Confirm.
- Under every answer, the Run a test button opens the same confirmation card, from the answer's text. With Ollama and the "Custom" provider, which make no proposals, it is the only way.
- The test is followed in the conversation's Run sub-tab.
The text that starts a test has 4,096 characters at most.
⚙ Execution settings¶
The ⚙ Execution settings button of the header sets what applies when the agent runs a test or explores the site. The settings are saved on the device.
| Setting | Effect | Default | Bound |
|---|---|---|---|
| Execution mode | Headless (no window, faster) or Live (the browser visible live, see Watch a test live) | Headless | — |
| Iterations on failure (1 = none) | If the test fails, the agent rewrites the script from the error and runs again, up to N attempts in total; each attempt is one call to the model | 1 | TEST_AI_MAX_ITERATIONS (3) |
| Agentic mode (observe + re-plan) | See below; always headless, it ignores iterations | off | — |
| Exploration: pages | Pages visited at most by an exploration | 8 | TEST_AI_MAX_CRAWL_PAGES (15) |
| Exploration: depth | Links followed from the start page (0 = that page only) | 2 | TEST_AI_MAX_CRAWL_DEPTH (3) |
Follow a test¶
The Run sub-tab shows the test's status and its tabs:
- Logs: the live log (request to the model, script received, Playwright output, iterations);
- Video: the test's video, the failure screenshots and the report, at the end;
- Script: the executed script;
- Anomaly: the anomaly created by a failure, with Open the anomaly;
- Live: in Live mode only.
| Status | Meaning |
|---|---|
| Queued | The test is accepted and about to start. |
| Running | The model writes the script, or Playwright runs it. |
| Succeeded | The script ran without error. |
| Failed | A real verdict: the script ran and a check failed. |
| Error | No verdict: a breakdown of the model, the container or the execution. |
| Cancelled | The test was stopped. |
The Stop button cuts the test, erases its working folder and deletes it (log, video, markers); no anomaly is created. Closing its conversation, or signing out, stops the running tests the same way.
The results¶
- The video of the whole test (WebM), in the Video tab, once the test is over.
- The failure screenshots: Playwright takes one at each failure; the Video tab shows them as thumbnails, to open full size. They are served only once the test is over.
- The executed script, in the Script tab.
- The report, in Markdown or PDF (buttons of the Video tab): request, status, duration, iterations, mode, script, last 50 log lines, artifacts, anomaly.
- The anomaly, when the test ends without succeeding (failure or error): "Auto:" followed by the start of the request, Medium severity, with the request, the status, the last script and the end of the error output. The "Anomalies" list is read again at once.
Retention. A test can be consulted only in its conversation, until the page is reloaded: the interface has no history view (the API has one, see For integrators). When Test-AI starts, working folders older than 30 days are erased, and a test left "Running" — cut by a restart — is closed as Error, with its reason in the log.
Agentic mode¶
Ticked in the settings, agentic mode replaces the simple loop: the agent runs a test, observes the page (the accessibility tree, no screenshot), then re-plans its script from what it sees, over several turns. The log follows each turn ("Agentic turn n / max", "↻ Re-planning…"). The loop stops:
- when the test succeeds;
- without progress (same script or same error repeated);
- when the token budget is spent (
TEST_AI_AGENTIC_TOKEN_BUDGET, 60,000 by default); - at the time limit (
TEST_AI_AGENTIC_WALL_CLOCK_MS, 15 minutes); - at the number of turns (
TEST_AI_MAX_AGENTIC_TURNS, 5); - if the agent deems the request unachievable.
Agentic mode costs several calls to the model per test. At most two agentic loops run at a time
(TEST_AI_MAX_CONCURRENT_AGENTIC).
Security: what isolates, what does not¶
What isolates. The script runs in the perfshop-playwright container, which mounts neither the PerfShop secrets,
nor the Test-AI database, nor the API keys. Test-AI drives it through the Docker relay, which only allows commands
inside that container. Each test works in its own folder of the playwright-workspace volume.
The validator rejects, before execution, a script that:
- uses
fs,child_process,osor raw network modules; - performs a dynamic
import(),evalorFunction(); - calls
process.exit()or modifiesprocess.env; - navigates to an address written in clear outside the target's origin;
- is empty, exceeds 16 KB or has more than 200 steps.
The log then shows "Script rejected by the safety validator" and the reason; with iterations, the agent rewrites its script.
What does not isolate. The validator reads the script's text: a built (concatenated) address escapes it. And the container's network is not restricted: the Internet and the stack's internal services answer — on purpose for the NAS's public target, and listed in the hardening inventory. The whole working volume is mounted read-write in the container.
Limits and server settings¶
| Limit | Value | Setting |
|---|---|---|
| Simultaneous tests (live or not) | 5 | PLAYWRIGHT_MAX_CONCURRENT |
| Duration of one Playwright execution | 5 minutes, then forced stop | PLAYWRIGHT_TIMEOUT_MS |
| Iterations | 3 at most | TEST_AI_MAX_ITERATIONS |
| Request | 4,096 characters | fixed |
| Script | 16 KB, 200 steps | fixed |
| Playwright output | 4 MiB, then stop | fixed |
| One call to the model | 90 seconds | fixed |
Troubleshooting¶
| Symptom | Cause and remedy |
|---|---|
| "No LLM provider configured — open "Configure LLM" first." | Save a provider (see Configure the language model). |
| "Too many concurrent runs — wait for one to finish." | 5 tests are already running (or 2 agentic loops). |
| "No virtual display available…" | Live mode: every display is taken (see Watch a test live). |
| Test in Error, without verdict | Read the Logs tab: the model did not answer, or the perfshop-playwright container (or the Docker relay) is stopped. |
| "Script rejected by the safety validator" | Rephrase the request, or turn on iterations: the agent rewrites its script from the reason. |
| "Video not yet available — the run is still in progress." | Normal during the test; the video shows at the end. |
| Repeated failures despite iterations | Make the request precise (pages, exact labels), quote the requirement by its code, or switch to agentic mode. |
| A test left "Running" after a Test-AI restart | It is closed as Error at the next start; run it again. |
For integrators¶
Every route needs a Test-AI session; an error returns {error_code, error, params}.
| Route | Role |
|---|---|
GET /api/runs |
The last 50 tests ({items}), explorations included. |
POST /api/runs |
Starts a test: {prompt, iterate?, max_iterations?, mode?: "headless" \| "live", agentic?} → 202 {id, status}; refusals 400, 409, 429, 503. |
GET /api/runs/:id |
The test and its artifacts ({run, artifacts}). |
GET /api/runs/:id/stream |
The live stream (Server-Sent Events); resume with Last-Event-ID. |
GET /api/runs/:id/video |
The video (425 during the test, 404 without video). |
GET /api/runs/:id/screenshots |
The failure screenshots ({items: [{id, name, size_bytes}]}). |
GET /api/runs/:id/screenshots/:artifactId |
One screenshot (425 during the test, 404, 400). |
GET /api/runs/:id/script |
The script (text/plain). |
DELETE /api/runs/:id |
Stops and deletes the test (204). |
Stream events: iteration_start, llm_request, llm_response, script, script_invalid, playwright_line,
playwright_exit, video, iteration_end, live_ready, agentic_turn_start, observation_captured, replan,
agentic_stop, system, error, complete, then closed at the end of the stream. A test's data lives in four
tables of the Test-AI database: runs, run_logs, run_artifacts, run_marks. The live routes (markers, report,
display) are described in Watch a test live.