@testdriverai/mcp 7.10.0-canary.0 → 7.10.1-test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +17 -0
- package/agent/index.js +116 -71
- package/agent/interface.js +13 -1
- package/agent/lib/commands.js +35 -15
- package/agent/lib/provision-commands.js +92 -11
- package/agent/lib/sandbox.js +263 -30
- package/agent/lib/sdk.js +16 -12
- package/agent/lib/system.js +107 -31
- package/ai/.claude-plugin/plugin.json +89 -4
- package/ai/agents/testdriver.md +4 -8
- package/ai/skills/testdriver-assert/SKILL.md +0 -1
- package/ai/skills/testdriver-aws-setup/SKILL.md +1 -1
- package/ai/skills/testdriver-caching/SKILL.md +13 -6
- package/ai/skills/testdriver-ci-cd/SKILL.md +57 -14
- package/ai/skills/testdriver-client/SKILL.md +10 -6
- package/ai/skills/testdriver-customizing-devices/SKILL.md +7 -5
- package/ai/skills/testdriver-dashcam/SKILL.md +36 -3
- package/ai/skills/testdriver-debugging-with-screenshots/SKILL.md +28 -4
- package/ai/skills/testdriver-device-config/SKILL.md +5 -5
- package/ai/skills/testdriver-find/SKILL.md +50 -11
- package/ai/skills/testdriver-generating-tests/SKILL.md +163 -8
- package/ai/skills/testdriver-hosted/SKILL.md +1 -1
- package/ai/skills/testdriver-machine-setup/SKILL.md +331 -0
- package/ai/skills/testdriver-making-assertions/SKILL.md +78 -2
- package/ai/skills/testdriver-mcp-workflow/SKILL.md +2 -2
- package/ai/skills/testdriver-parse/SKILL.md +1 -1
- package/ai/skills/testdriver-performing-actions/SKILL.md +97 -3
- package/ai/skills/testdriver-provision/SKILL.md +0 -20
- package/ai/skills/testdriver-quickstart/SKILL.md +299 -21
- package/ai/skills/testdriver-reusable-code/SKILL.md +3 -3
- package/ai/skills/testdriver-running-tests/SKILL.md +1 -1
- package/ai/skills/testdriver-screenshot/SKILL.md +5 -5
- package/ai/skills/testdriver-scroll/SKILL.md +30 -160
- package/ai/skills/testdriver-test-writer/SKILL.md +3 -5
- package/ai/skills/testdriver-testdriver/SKILL.md +3 -7
- package/ai/skills/testdriver-wait/SKILL.md +1 -1
- package/{docs/v7/ai.mdx → ai/skills/testdriver:ai/SKILL.md} +3 -4
- package/ai/skills/testdriver:assert/SKILL.md +315 -0
- package/ai/skills/testdriver:aws-setup/SKILL.md +448 -0
- package/ai/skills/testdriver:cache/SKILL.md +221 -0
- package/ai/skills/testdriver:caching/SKILL.md +124 -0
- package/ai/skills/testdriver:captcha/SKILL.md +158 -0
- package/ai/skills/testdriver:ci-cd/SKILL.md +659 -0
- package/ai/skills/testdriver:click/SKILL.md +286 -0
- package/ai/skills/testdriver:client/SKILL.md +477 -0
- package/ai/skills/testdriver:customizing-devices/SKILL.md +319 -0
- package/ai/skills/testdriver:dashcam/SKILL.md +451 -0
- package/ai/skills/testdriver:debugging-with-screenshots/SKILL.md +415 -0
- package/{docs/v7/device-config.mdx → ai/skills/testdriver:device-config/SKILL.md} +8 -8
- package/ai/skills/testdriver:double-click/SKILL.md +102 -0
- package/ai/skills/testdriver:elements/SKILL.md +605 -0
- package/ai/skills/testdriver:enterprise/SKILL.md +7 -0
- package/ai/skills/testdriver:errors/SKILL.md +246 -0
- package/ai/skills/testdriver:events/SKILL.md +356 -0
- package/ai/skills/testdriver:exec/SKILL.md +317 -0
- package/ai/skills/testdriver:find/SKILL.md +860 -0
- package/ai/skills/testdriver:focus-application/SKILL.md +293 -0
- package/ai/skills/testdriver:generating-tests/SKILL.md +25 -0
- package/ai/skills/testdriver:hosted/SKILL.md +156 -0
- package/ai/skills/testdriver:hover/SKILL.md +278 -0
- package/{docs/v7/locating-elements.mdx → ai/skills/testdriver:locating-elements/SKILL.md} +3 -3
- package/ai/skills/testdriver:making-assertions/SKILL.md +32 -0
- package/ai/skills/testdriver:mcp/SKILL.md +7 -0
- package/ai/skills/testdriver:mouse-down/SKILL.md +161 -0
- package/ai/skills/testdriver:mouse-up/SKILL.md +164 -0
- package/ai/skills/testdriver:parse/SKILL.md +236 -0
- package/ai/skills/testdriver:performing-actions/SKILL.md +53 -0
- package/ai/skills/testdriver:press-keys/SKILL.md +348 -0
- package/ai/skills/testdriver:provision/SKILL.md +331 -0
- package/ai/skills/testdriver:quickstart/SKILL.md +172 -0
- package/ai/skills/testdriver:redraw/SKILL.md +214 -0
- package/ai/skills/testdriver:reusable-code/SKILL.md +249 -0
- package/ai/skills/testdriver:right-click/SKILL.md +123 -0
- package/{docs/v7/running-tests.mdx → ai/skills/testdriver:running-tests/SKILL.md} +4 -4
- package/ai/skills/testdriver:screenshot/SKILL.md +248 -0
- package/ai/skills/testdriver:screenshots/SKILL.md +184 -0
- package/ai/skills/testdriver:scroll/SKILL.md +205 -0
- package/ai/skills/testdriver:secrets/SKILL.md +115 -0
- package/ai/skills/testdriver:self-hosted/SKILL.md +147 -0
- package/ai/skills/testdriver:test-results-json/SKILL.md +257 -0
- package/ai/skills/testdriver:testdriver/SKILL.md +624 -0
- package/ai/skills/testdriver:type/SKILL.md +357 -0
- package/ai/skills/testdriver:variables/SKILL.md +111 -0
- package/ai/skills/testdriver:wait/SKILL.md +50 -0
- package/{docs/v7/waiting-for-elements.mdx → ai/skills/testdriver:waiting-for-elements/SKILL.md} +3 -3
- package/ai/skills/testdriver:what-is-testdriver/SKILL.md +54 -0
- package/debugger/index.html +12 -0
- package/docs/_data/examples-manifest.json +54 -46
- package/docs/_data/examples-manifest.schema.json +12 -2
- package/docs/_scripts/extract-example-urls.js +21 -3
- package/docs/_scripts/generate-examples.js +64 -16
- package/docs/changelog.mdx +29 -2
- package/docs/claude-mcp-plugin.mdx +65 -18
- package/docs/docs.json +16 -33
- package/docs/snippets/tests/scroll-yaml.mdx +2 -2
- package/docs/v6/commands/scroll-until-image.mdx +1 -1
- package/docs/v6/commands/scroll-until-text.mdx +2 -2
- package/docs/v6/commands/scroll.mdx +2 -2
- package/docs/v7/_drafts/agents.mdx +0 -4
- package/docs/v7/_drafts/best-practices.mdx +0 -12
- package/docs/v7/_drafts/commands/scroll-until-image.mdx +1 -1
- package/docs/v7/_drafts/commands/scroll-until-text.mdx +2 -2
- package/docs/v7/_drafts/commands/scroll.mdx +1 -1
- package/docs/v7/_drafts/configuration.mdx +0 -12
- package/docs/v7/_drafts/faq.mdx +2 -10
- package/docs/v7/_drafts/readme.mdx +0 -1
- package/docs/v7/_drafts/troubleshooting.mdx +1 -4
- package/docs/v7/assert.mdx +0 -1
- package/docs/v7/aws-setup.mdx +1 -1
- package/docs/v7/caching.mdx +14 -10
- package/docs/v7/ci-cd.mdx +98 -14
- package/docs/v7/client.mdx +10 -6
- package/docs/v7/copilot/auto-healing.mdx +167 -18
- package/docs/v7/copilot/running-tests.mdx +915 -54
- package/docs/v7/customizing-devices.mdx +7 -5
- package/docs/v7/dashcam.mdx +36 -3
- package/docs/v7/debugging-with-screenshots.mdx +31 -7
- package/docs/v7/examples/ai.mdx +13 -8
- package/docs/v7/examples/assert.mdx +1 -1
- package/docs/v7/examples/chrome-extension.mdx +30 -13
- package/docs/v7/examples/element-not-found.mdx +1 -1
- package/docs/v7/examples/findall-coffee-icons.mdx +3 -2
- package/docs/v7/examples/formatted-logging.mdx +74 -0
- package/docs/v7/examples/hover-image.mdx +1 -1
- package/docs/v7/examples/hover-text-with-description.mdx +2 -2
- package/docs/v7/examples/hover-text.mdx +1 -1
- package/docs/v7/examples/installer.mdx +1 -1
- package/docs/v7/examples/launch-vscode-linux.mdx +27 -27
- package/docs/v7/examples/match-image.mdx +1 -1
- package/docs/v7/examples/parse.mdx +3 -2
- package/docs/v7/examples/press-keys.mdx +2 -2
- package/docs/v7/examples/scroll-keyboard.mdx +2 -2
- package/docs/v7/examples/scroll-until-text.mdx +1 -1
- package/docs/v7/examples/scroll.mdx +1 -1
- package/docs/v7/examples/type.mdx +1 -1
- package/docs/v7/find.mdx +50 -11
- package/docs/v7/generating-tests.mdx +166 -10
- package/docs/v7/hosted.mdx +1 -1
- package/docs/v7/making-assertions.mdx +81 -4
- package/docs/v7/parse.mdx +1 -1
- package/docs/v7/performing-actions.mdx +100 -5
- package/docs/v7/provision.mdx +0 -20
- package/docs/v7/quickstart.mdx +299 -21
- package/docs/v7/reusable-code.mdx +3 -3
- package/docs/v7/screenshot.mdx +5 -5
- package/docs/v7/scroll.mdx +30 -160
- package/docs/v7/wait.mdx +1 -1
- package/examples/chrome-extension.test.mjs +29 -12
- package/examples/config.mjs +1 -1
- package/examples/launch-vscode-linux.test.mjs +25 -25
- package/interfaces/cli/commands/init.js +84 -2
- package/interfaces/vitest-plugin.mjs +51 -61
- package/lib/core/Dashcam.js +43 -2
- package/lib/core/index.d.ts +13 -1
- package/lib/github-comment.mjs +11 -5
- package/lib/init-project.js +98 -44
- package/lib/install-clients.js +470 -0
- package/lib/provision.js +749 -0
- package/lib/resolve-channel.js +2 -2
- package/lib/sentry.js +15 -2
- package/lib/vitest/hooks.mjs +44 -34
- package/mcp-server/README.md +32 -0
- package/mcp-server/dist/core/actions.d.ts +176 -0
- package/mcp-server/dist/core/actions.js +753 -0
- package/mcp-server/dist/env-utils.d.ts +45 -0
- package/mcp-server/dist/env-utils.js +63 -0
- package/mcp-server/dist/provision-types.d.ts +6 -2
- package/mcp-server/dist/provision-types.js +3 -1
- package/mcp-server/dist/server.mjs +449 -751
- package/mcp-server/package-lock.json +384 -1
- package/mcp-server/package.json +5 -2
- package/mcp-server/src/core/actions.ts +912 -0
- package/mcp-server/src/env-utils.test.ts +82 -0
- package/mcp-server/src/env-utils.ts +77 -0
- package/mcp-server/src/provision-types.ts +4 -1
- package/mcp-server/src/server.ts +533 -954
- package/mcp-server/tsconfig.json +1 -1
- package/mcp-server/vitest.config.ts +7 -0
- package/package.json +15 -3
- package/sdk.d.ts +11 -9
- package/sdk.js +116 -746
- package/setup/aws/spawn-runner.sh +24 -3
- package/docs/v7/_drafts/caching-ai.mdx +0 -215
- package/docs/v7/_drafts/caching.mdx +0 -366
- package/docs/v7/_drafts/prompt-cache.mdx +0 -200
- package/docs/v7/copilot/creating-tests.mdx +0 -156
- package/docs/v7/copilot/github.mdx +0 -143
- package/docs/v7/copilot/setup.mdx +0 -143
- package/docs/v7/examples/exec-output.mdx +0 -84
- package/docs/v7/examples/exec-pwsh.mdx +0 -82
- package/docs/v7/examples/focus-window.mdx +0 -61
- package/docs/v7/examples/scroll-until-image.mdx +0 -82
- package/docs/v7/examples/windows-installer.mdx +0 -95
- package/examples/formatted-logging.test.mjs +0 -27
- package/examples/match-image.test.mjs +0 -55
- package/manual/exec-stream-logs.test.mjs +0 -25
package/docs/v7/find.mdx
CHANGED
|
@@ -50,8 +50,12 @@ const element = await testdriver.find(description, options)
|
|
|
50
50
|
- `"any"` — No wrapping, uses the description as-is (default behavior)
|
|
51
51
|
</ParamField>
|
|
52
52
|
|
|
53
|
-
<ParamField path="zoom" type="boolean" default={
|
|
54
|
-
Two-phase zoom mode for better precision in crowded UIs with many similar elements.
|
|
53
|
+
<ParamField path="zoom" type="boolean" default={false}>
|
|
54
|
+
Two-phase zoom mode for better precision in crowded UIs with many similar elements. Disabled by default.
|
|
55
|
+
</ParamField>
|
|
56
|
+
|
|
57
|
+
<ParamField path="verify" type="boolean" default={false}>
|
|
58
|
+
Enable AI verification of the located element. When `true`, a second AI call checks that the coordinates returned actually correspond to the requested element, catching hallucinated or incorrect positions. Disabled by default for lower latency.
|
|
55
59
|
</ParamField>
|
|
56
60
|
|
|
57
61
|
<ParamField path="ai" type="object">
|
|
@@ -335,17 +339,17 @@ The `timeout` option:
|
|
|
335
339
|
|
|
336
340
|
## Zoom Mode
|
|
337
341
|
|
|
338
|
-
Zoom mode is **
|
|
342
|
+
Zoom mode is **disabled by default**. It uses a two-phase approach for better precision when locating elements, especially in crowded UIs with many similar elements.
|
|
339
343
|
|
|
340
|
-
To
|
|
344
|
+
To enable zoom for a specific find call, pass `zoom: true`:
|
|
341
345
|
|
|
342
346
|
```javascript
|
|
343
|
-
//
|
|
344
|
-
const extensionsBtn = await testdriver.find('extensions puzzle icon in Chrome toolbar');
|
|
347
|
+
// Enable zoom for better precision in crowded UIs
|
|
348
|
+
const extensionsBtn = await testdriver.find('extensions puzzle icon in Chrome toolbar', { zoom: true });
|
|
345
349
|
await extensionsBtn.click();
|
|
346
350
|
|
|
347
|
-
//
|
|
348
|
-
const largeButton = await testdriver.find('big hero button'
|
|
351
|
+
// Without zoom (default)
|
|
352
|
+
const largeButton = await testdriver.find('big hero button');
|
|
349
353
|
```
|
|
350
354
|
|
|
351
355
|
### How Zoom Mode Works
|
|
@@ -358,13 +362,48 @@ const largeButton = await testdriver.find('big hero button', { zoom: false });
|
|
|
358
362
|
This two-phase approach gives the AI a higher-resolution view of the target area, improving accuracy when multiple similar elements are close together.
|
|
359
363
|
|
|
360
364
|
<Tip>
|
|
361
|
-
You may want to
|
|
362
|
-
- Targeting
|
|
363
|
-
- You
|
|
365
|
+
You may want to enable zoom with `zoom: true` when:
|
|
366
|
+
- Targeting small elements in crowded UIs with many similar elements
|
|
367
|
+
- You need extra precision for closely spaced UI elements
|
|
364
368
|
</Tip>
|
|
365
369
|
|
|
370
|
+
## Verify Mode
|
|
371
|
+
|
|
372
|
+
Verify mode is **disabled by default**. When enabled, a second AI call checks that the coordinates returned by `find()` actually correspond to the requested element, catching hallucinated or incorrect positions.
|
|
373
|
+
|
|
374
|
+
```javascript
|
|
375
|
+
// Enable verification for critical interactions
|
|
376
|
+
const deleteBtn = await testdriver.find('delete account button', { verify: true });
|
|
377
|
+
await deleteBtn.click();
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### How Verify Mode Works
|
|
381
|
+
|
|
382
|
+
1. **Phase 1**: AI locates the element and returns coordinates
|
|
383
|
+
2. **Phase 2**: A second AI call examines the screenshot at those coordinates to confirm the element matches the description
|
|
384
|
+
3. **Result**: If verification fails, the find is retried or marked as not found
|
|
385
|
+
|
|
386
|
+
### Combining Zoom and Verify
|
|
387
|
+
|
|
388
|
+
For maximum accuracy, enable both `zoom` and `verify` together. This is useful for critical interactions where clicking the wrong element could cause cascading failures:
|
|
389
|
+
|
|
390
|
+
```javascript
|
|
391
|
+
// Maximum accuracy: zoom for precision + verify to catch hallucinations
|
|
392
|
+
const element = await testdriver.find('small cancel icon next to the subscription', {
|
|
393
|
+
zoom: true,
|
|
394
|
+
verify: true,
|
|
395
|
+
});
|
|
396
|
+
await element.click();
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
<Warning>
|
|
400
|
+
Both `zoom` and `verify` add extra AI calls per `find()` invocation, which increases latency and API usage. When both are enabled, each find may make up to 3 AI calls. **Rate limiting may occur** if many find calls use these options in rapid succession. Use them selectively for critical interactions rather than on every find call.
|
|
401
|
+
</Warning>
|
|
402
|
+
|
|
366
403
|
## Cache Options
|
|
367
404
|
|
|
405
|
+
When a test completes successfully, the result of each `find()` is cached. On later runs, TestDriver reuses the cached match instead of making a fresh AI call, which significantly speeds up locating the same element. The cache lives in your [dashboard](https://console.testdriver.ai/cache) and is shared across runs — see the [Cache](/v7/cache) page for how matching, thresholds, and invalidation work.
|
|
406
|
+
|
|
368
407
|
Control caching behavior to optimize performance, especially when using dynamic variables in prompts.
|
|
369
408
|
|
|
370
409
|
### Custom Cache Key
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
title: "Explore"
|
|
3
|
+
sidebarTitle: "Explore"
|
|
4
|
+
description: "Generate tests by exploring your app with the AI vision agent"
|
|
5
|
+
icon: "compass"
|
|
5
6
|
---
|
|
6
7
|
|
|
8
|
+
Start by exploring your app. This is where tests begin: you describe a flow in plain English, and the TestDriver vision agent clicks, types, and reads the screen to figure it out — then writes the test for you. No selectors, no DOM, no brittle locators. Just describe what you want to test and let the agent discover the rest.
|
|
9
|
+
|
|
10
|
+
There are two ways to explore: chatting interactively with your AI assistant through the TestDriver MCP server, or handing a coding agent our instructions file and prompting it to generate a test.
|
|
11
|
+
|
|
12
|
+
<Info>
|
|
13
|
+
Both paths need an MCP-capable AI coding assistant. If you don't have one yet, start with **GitHub Copilot** — there's a [free tier](https://github.com/features/copilot/plans), no credit card required. See [Run → Setup](/v7/copilot/running-tests#setup) for the full install and sign-in walkthrough.
|
|
14
|
+
</Info>
|
|
15
|
+
|
|
7
16
|
## Instructions for Coding Agents
|
|
8
17
|
|
|
9
|
-
We recommend starting with [our quickstart](./quickstart) then supplying your coding agent with our agent instructions file.
|
|
18
|
+
We recommend starting with [our quickstart](./quickstart), then supplying your coding agent with our agent instructions file.
|
|
10
19
|
|
|
11
20
|
<Card title="TestDriver Agent Instructions" icon="link" arrow="true" horizontal href="https://github.com/testdriverai/testdriverai/blob/main/ai/agents/testdriver.md?plain=1">
|
|
12
21
|
Copy the current version of our agent instructions to provide your coding agent with up-to-date instructions on how to generate TestDriver tests.
|
|
@@ -24,13 +33,160 @@ Push Submit button
|
|
|
24
33
|
Verify new page contains expected text 'logged in'
|
|
25
34
|
```
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
<Info>Explicit commands are preferred for production tests, as they are cheaper, faster, and more reliable.</Info>
|
|
37
|
+
|
|
38
|
+
## Start a Conversation
|
|
39
|
+
|
|
40
|
+
With TestDriver's MCP server and your AI assistant (GitHub Copilot, Cursor, or Claude Desktop), you can create tests by chatting with an AI agent. The agent spawns a virtual machine, executes actions, and writes test code for you.
|
|
41
|
+
|
|
42
|
+
Open your AI assistant's chat. If your project has no other agents configured, the TestDriver agent is used by default. Otherwise, select **testdriver** from the agent dropdown in the chat panel.
|
|
28
43
|
|
|
29
|
-
|
|
44
|
+
Describe what you want to test:
|
|
30
45
|
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
await testdriver.ai('dismiss any popups or modals that appear');
|
|
46
|
+
```
|
|
47
|
+
Create a test that logs into my app at https://myapp.com
|
|
34
48
|
```
|
|
35
49
|
|
|
36
|
-
|
|
50
|
+
The agent will:
|
|
51
|
+
1. Start a new session and spawn a Linux virtual machine
|
|
52
|
+
2. Launch Chrome and navigate to your URL
|
|
53
|
+
3. Execute actions based on your instructions
|
|
54
|
+
4. Write the test code to a `.test.mjs` file
|
|
55
|
+
|
|
56
|
+
<Note>
|
|
57
|
+
The TestDriver agent appears in the agent selection dropdown if you have other agents configured (like `copilot-instructions.md` or other `.agent.md` files). Make sure to select **testdriver** to use TestDriver's MCP tools.
|
|
58
|
+
</Note>
|
|
59
|
+
|
|
60
|
+
## Live Preview Panel
|
|
61
|
+
|
|
62
|
+
When the agent starts a session, a **live preview panel** opens in your editor. This lets you:
|
|
63
|
+
|
|
64
|
+
- **Watch tests execute** in real-time
|
|
65
|
+
- **Interact with the VM** — click, type, and navigate manually
|
|
66
|
+
- **Debug issues** — see exactly what the AI sees
|
|
67
|
+
|
|
68
|
+
<Note>
|
|
69
|
+
The live preview panel requires the TestDriver VS Code extension. Set `TD_PREVIEW=ide` in your MCP configuration to enable it. See the [Run page](/v7/copilot/running-tests) for all device and preview options.
|
|
70
|
+
</Note>
|
|
71
|
+
|
|
72
|
+
## Interactive Workflow
|
|
73
|
+
|
|
74
|
+
The recommended workflow for exploring and creating tests:
|
|
75
|
+
|
|
76
|
+
<Steps>
|
|
77
|
+
<Step title="Describe Your Test">
|
|
78
|
+
Tell the agent what you want to test:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
Test the checkout flow on https://shop.example.com
|
|
82
|
+
```
|
|
83
|
+
</Step>
|
|
84
|
+
|
|
85
|
+
<Step title="Watch and Guide">
|
|
86
|
+
The agent will start executing. Watch the preview panel and provide guidance if needed:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
The login modal appeared. Use test@example.com and password123
|
|
90
|
+
```
|
|
91
|
+
</Step>
|
|
92
|
+
|
|
93
|
+
<Step title="Add Assertions">
|
|
94
|
+
Ask the agent to verify specific conditions:
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
Assert that the order confirmation page is shown with the order number
|
|
98
|
+
```
|
|
99
|
+
</Step>
|
|
100
|
+
|
|
101
|
+
<Step title="Review the Code">
|
|
102
|
+
The agent writes test code as it works. Review the generated `.test.mjs` file and make any adjustments.
|
|
103
|
+
</Step>
|
|
104
|
+
</Steps>
|
|
105
|
+
|
|
106
|
+
## Example Conversation
|
|
107
|
+
|
|
108
|
+
Here's a complete example of exploring and creating a login test:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
You: Create a test for the login flow at https://console.testdriver.ai
|
|
112
|
+
|
|
113
|
+
Agent: I'll create a test for the login flow. Starting a session...
|
|
114
|
+
[Screenshot: Login page loaded]
|
|
115
|
+
|
|
116
|
+
I can see the login page. Let me find the email input.
|
|
117
|
+
[Screenshot: Email input highlighted]
|
|
118
|
+
|
|
119
|
+
Now I'll type the email and find the password field...
|
|
120
|
+
|
|
121
|
+
You: Use test@example.com for the email
|
|
122
|
+
|
|
123
|
+
Agent: Got it. Typing test@example.com...
|
|
124
|
+
[Screenshot: Email entered]
|
|
125
|
+
|
|
126
|
+
Now entering the password and clicking Sign In...
|
|
127
|
+
[Screenshot: Dashboard loaded]
|
|
128
|
+
|
|
129
|
+
✅ Login successful! I've written the test to tests/login.test.mjs
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Generated Test Code
|
|
133
|
+
|
|
134
|
+
The agent generates standard Vitest test files:
|
|
135
|
+
|
|
136
|
+
```javascript tests/login.test.mjs
|
|
137
|
+
import { describe, expect, it } from "vitest";
|
|
138
|
+
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
139
|
+
|
|
140
|
+
describe("Login Flow", () => {
|
|
141
|
+
it("should log in successfully", async (context) => {
|
|
142
|
+
const testdriver = TestDriver(context);
|
|
143
|
+
|
|
144
|
+
await testdriver.provision.chrome({
|
|
145
|
+
url: "https://console.testdriver.ai"
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const emailInput = await testdriver.find("email input field");
|
|
149
|
+
await emailInput.click();
|
|
150
|
+
await testdriver.type("test@example.com");
|
|
151
|
+
|
|
152
|
+
const passwordInput = await testdriver.find("password input field");
|
|
153
|
+
await passwordInput.click();
|
|
154
|
+
await testdriver.type("password123");
|
|
155
|
+
|
|
156
|
+
const signInButton = await testdriver.find("Sign In button");
|
|
157
|
+
await signInButton.click();
|
|
158
|
+
|
|
159
|
+
const result = await testdriver.assert("dashboard is visible");
|
|
160
|
+
expect(result).toBeTruthy();
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Tips for Better Tests
|
|
166
|
+
|
|
167
|
+
<AccordionGroup>
|
|
168
|
+
<Accordion title="Be specific with element descriptions">
|
|
169
|
+
Instead of "click the button", say "click the blue Sign In button in the header". More context helps the AI find the right element.
|
|
170
|
+
</Accordion>
|
|
171
|
+
<Accordion title="Add waits for dynamic content">
|
|
172
|
+
If your app has animations or loading states, tell the agent to wait:
|
|
173
|
+
```
|
|
174
|
+
Wait for the loading spinner to disappear before continuing
|
|
175
|
+
```
|
|
176
|
+
</Accordion>
|
|
177
|
+
<Accordion title="Use assertions liberally">
|
|
178
|
+
Add assertions after each major action to catch regressions early:
|
|
179
|
+
```
|
|
180
|
+
Assert that the product was added to the cart
|
|
181
|
+
```
|
|
182
|
+
</Accordion>
|
|
183
|
+
<Accordion title="Break complex flows into steps">
|
|
184
|
+
For long workflows, create the test incrementally and verify each step works before moving on.
|
|
185
|
+
</Accordion>
|
|
186
|
+
</AccordionGroup>
|
|
187
|
+
|
|
188
|
+
## Next
|
|
189
|
+
|
|
190
|
+
<Card title="Learn" icon="brain" arrow="true" horizontal href="/v7/caching">
|
|
191
|
+
Once the agent has explored your app, TestDriver caches what it discovers so your tests replay instantly without re-reasoning over the screen every time.
|
|
192
|
+
</Card>
|
package/docs/v7/hosted.mdx
CHANGED
|
@@ -77,7 +77,7 @@ To prevent tests from failing due to exceeding your license slot limit, we recom
|
|
|
77
77
|
|
|
78
78
|
```javascript vitest.config.mjs
|
|
79
79
|
import { defineConfig } from 'vitest/config';
|
|
80
|
-
import
|
|
80
|
+
import TestDriver from 'testdriverai/vitest';
|
|
81
81
|
|
|
82
82
|
export default defineConfig({
|
|
83
83
|
test: {
|
|
@@ -1,12 +1,83 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
title: "Validate"
|
|
3
|
+
sidebarTitle: "Validate"
|
|
4
|
+
description: "Locate elements and verify app state with AI-powered assertions"
|
|
5
|
+
icon: "circle-check"
|
|
5
6
|
---
|
|
6
7
|
|
|
8
|
+
Once a test runs, validate that the app did what it should. Validation has two parts: locating the elements you want to check, and making assertions about the state of your app. TestDriver uses AI as a judge, returning a boolean plus reasoning about whether your app is in the expected state.
|
|
9
|
+
|
|
10
|
+
## Locating Elements
|
|
11
|
+
|
|
12
|
+
### Locating Single Elements
|
|
13
|
+
|
|
14
|
+
Use natural language to describe elements. Descriptions should be specific enough to locate the element, but not too-specific that they break with minor UI changes. For example:
|
|
15
|
+
|
|
16
|
+
```javascript
|
|
17
|
+
await testdriver.find('email input field');
|
|
18
|
+
await testdriver.find('first product card in the grid');
|
|
19
|
+
await testdriver.find('dropdown menu labeled "Country"');
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
<Info>TestDriver will cache found elements for improved performance on subsequent calls. Learn more about [element caching here](/v7/caching).</Info>
|
|
23
|
+
|
|
24
|
+
### Debugging Found Elements
|
|
25
|
+
|
|
26
|
+
After finding an element, you can inspect its properties for debugging:
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
const button = await testdriver.find('submit button');
|
|
30
|
+
console.log(button);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This outputs all element properties:
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
{
|
|
37
|
+
description: 'submit button',
|
|
38
|
+
found: true,
|
|
39
|
+
x: 150,
|
|
40
|
+
y: 300,
|
|
41
|
+
coordinates: { x: 150, y: 300, centerX: 200, centerY: 320 },
|
|
42
|
+
threshold: 0.8,
|
|
43
|
+
confidence: 0.95,
|
|
44
|
+
similarity: 0.92,
|
|
45
|
+
selector: 'button[type="submit"]',
|
|
46
|
+
cache: {
|
|
47
|
+
hit: true,
|
|
48
|
+
strategy: 'pixel-diff',
|
|
49
|
+
createdAt: '2025-01-15T10:30:00Z',
|
|
50
|
+
diffPercent: 0.02,
|
|
51
|
+
imageUrl: 'https://...'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Working with Multiple Elements
|
|
57
|
+
|
|
58
|
+
Find and interact with multiple elements:
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
// Find all matching elements
|
|
62
|
+
const products = await testdriver.findAll('product card');
|
|
63
|
+
console.log(`Found ${products.length} products`);
|
|
64
|
+
|
|
65
|
+
// Interact with each
|
|
66
|
+
for (const product of products) {
|
|
67
|
+
const title = await product.find('title text');
|
|
68
|
+
console.log('Product:', title.text);
|
|
69
|
+
|
|
70
|
+
await product.find('add to cart button').click();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Or find specific element
|
|
74
|
+
const firstProduct = products[0];
|
|
75
|
+
await firstProduct.click();
|
|
76
|
+
```
|
|
77
|
+
|
|
7
78
|
## Making Assertions
|
|
8
79
|
|
|
9
|
-
Use AI-powered assertions to verify application state:
|
|
80
|
+
Use AI-powered assertions to verify application state. TestDriver acts as a judge: it evaluates your natural-language statement against the current state of the app and returns a boolean plus reasoning explaining the verdict.
|
|
10
81
|
|
|
11
82
|
```javascript
|
|
12
83
|
// Verify visibility
|
|
@@ -30,3 +101,9 @@ await testdriver.assert('form has red border');
|
|
|
30
101
|
```
|
|
31
102
|
|
|
32
103
|
<Info>Assertions are not cached and always re-evaluated to ensure accuracy.</Info>
|
|
104
|
+
|
|
105
|
+
## Next
|
|
106
|
+
|
|
107
|
+
<Card title="Adapt" icon="arrows-rotate" href="/v7/performing-actions">
|
|
108
|
+
Drive your app forward by performing actions on the elements you've located and validated.
|
|
109
|
+
</Card>
|
package/docs/v7/parse.mdx
CHANGED
|
@@ -121,7 +121,7 @@ console.log(`Found ${buttons.length} buttons`);
|
|
|
121
121
|
|
|
122
122
|
```javascript
|
|
123
123
|
import { describe, expect, it } from "vitest";
|
|
124
|
-
import { TestDriver } from "testdriverai/
|
|
124
|
+
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
125
125
|
|
|
126
126
|
describe("Login Page", () => {
|
|
127
127
|
it("should have expected form elements", async (context) => {
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
title: "Adapt"
|
|
3
|
+
sidebarTitle: "Adapt"
|
|
4
|
+
description: "Perform actions and handle dynamic, async UI so tests adapt to change"
|
|
5
|
+
icon: "arrows-rotate"
|
|
5
6
|
---
|
|
6
7
|
|
|
8
|
+
Real apps move, load, and change. Adapt your tests to handle it.
|
|
9
|
+
|
|
10
|
+
Once you've [generated](/v7/generating-tests) and [learned](/v7/caching) your tests and gotten them [running](/v7/copilot/running-tests), the next challenge is the real world: buttons appear after a spinner, pages navigate, animations play, and content streams in over the network. To keep tests reliable, you need to perform the right actions and handle timing so your tests adapt to how the UI actually behaves instead of breaking.
|
|
11
|
+
|
|
7
12
|
## Performing Actions
|
|
8
13
|
|
|
9
14
|
TestDriver provides a variety of actions you can perform, like [clicking](/v7/click), [typing](/v7/type), [hovering](/v7/hover), and [scrolling](/v7/scroll). For a full list, see the [API Reference](/v7/click).
|
|
@@ -27,7 +32,6 @@ await testdriver.find('dropdown menu').hover();
|
|
|
27
32
|
|
|
28
33
|
// Scrolling
|
|
29
34
|
await testdriver.scroll('down', 500);
|
|
30
|
-
await testdriver.scrollUntilText('Footer content');
|
|
31
35
|
|
|
32
36
|
// Waiting
|
|
33
37
|
await testdriver.wait(2000); // Wait 2 seconds for animation/state change
|
|
@@ -37,7 +41,7 @@ const price = await testdriver.extract('the total price');
|
|
|
37
41
|
const orderNumber = await testdriver.extract('the order confirmation number');
|
|
38
42
|
```
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
### Chaining Actions
|
|
41
45
|
|
|
42
46
|
TestDriver supports method chaining for cleaner code:
|
|
43
47
|
|
|
@@ -52,3 +56,94 @@ Or save element reference for later use:
|
|
|
52
56
|
const button = await testdriver.find('submit button');
|
|
53
57
|
await button.click();
|
|
54
58
|
```
|
|
59
|
+
|
|
60
|
+
## Waiting for Dynamic Content
|
|
61
|
+
|
|
62
|
+
By default, `find()` automatically polls for up to 10 seconds, retrying every 5 seconds until the element is found. This means most elements that appear after short async operations will be found without any extra configuration.
|
|
63
|
+
|
|
64
|
+
For longer operations, increase the `timeout`:
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
// Default behavior - polls for up to 10 seconds automatically
|
|
68
|
+
const element = await testdriver.find('Loading complete indicator');
|
|
69
|
+
await element.click();
|
|
70
|
+
|
|
71
|
+
// Wait up to 30 seconds for slower operations
|
|
72
|
+
const element = await testdriver.find('Loading complete indicator', { timeout: 30000 });
|
|
73
|
+
await element.click();
|
|
74
|
+
|
|
75
|
+
// Useful after actions that trigger loading states
|
|
76
|
+
await testdriver.find('submit button').click();
|
|
77
|
+
await testdriver.find('success message', { timeout: 15000 });
|
|
78
|
+
|
|
79
|
+
// Disable polling for instant checks
|
|
80
|
+
const toast = await testdriver.find('notification toast', { timeout: 0 });
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Flake Prevention
|
|
84
|
+
|
|
85
|
+
TestDriver automatically waits for the screen and network to stabilize after each action using **redraw detection**. This prevents flaky tests caused by animations, loading states, or dynamic content updates.
|
|
86
|
+
|
|
87
|
+
<Note>
|
|
88
|
+
Redraw detection adds a small delay after each action but significantly reduces test flakiness.
|
|
89
|
+
</Note>
|
|
90
|
+
|
|
91
|
+
For example, when clicking a submit button that navigates to a new page:
|
|
92
|
+
|
|
93
|
+
```javascript
|
|
94
|
+
// Click submit - TestDriver automatically waits for the new page to load
|
|
95
|
+
await testdriver.find('submit button').click();
|
|
96
|
+
|
|
97
|
+
// By the time this runs, the page has fully loaded and stabilized
|
|
98
|
+
await testdriver.assert('dashboard is displayed');
|
|
99
|
+
await testdriver.find('welcome message');
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Without redraw detection, you'd need manual waits or retries to handle the page transition. TestDriver handles this automatically by detecting when the screen stops changing and network requests complete.
|
|
103
|
+
|
|
104
|
+
You can disable redraw detection or customize its behavior:
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
// Disable redraw detection for faster tests (less reliable)
|
|
108
|
+
const testdriver = TestDriver(context, {
|
|
109
|
+
redraw: false
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Here is an example of customizing redraw detection:
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
// Fine-tune redraw detection
|
|
117
|
+
const testdriver = TestDriver(context, {
|
|
118
|
+
redraw: {
|
|
119
|
+
enabled: true,
|
|
120
|
+
diffThreshold: 0.1, // Pixel difference threshold (0-1)
|
|
121
|
+
screenRedraw: true, // Monitor screen changes
|
|
122
|
+
networkMonitor: true, // Wait for network idle
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Simple Delays with `wait()`
|
|
128
|
+
|
|
129
|
+
For simple pauses — waiting for animations, transitions, or state changes after an action — use `wait()`:
|
|
130
|
+
|
|
131
|
+
```javascript
|
|
132
|
+
// Wait for an animation to complete
|
|
133
|
+
await testdriver.find('menu toggle').click();
|
|
134
|
+
await testdriver.wait(2000);
|
|
135
|
+
|
|
136
|
+
// Wait for a page transition to settle
|
|
137
|
+
await testdriver.find('next page button').click();
|
|
138
|
+
await testdriver.wait(1000);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
<Note>
|
|
142
|
+
For waiting for specific **elements** to appear, prefer `find()` with a `timeout` option. Use `wait()` only for simple time-based pauses.
|
|
143
|
+
</Note>
|
|
144
|
+
|
|
145
|
+
Once your tests can reliably act on a changing UI and [assert](/v7/making-assertions) the results, the next step is figuring out what happened when something does go wrong.
|
|
146
|
+
|
|
147
|
+
<Card title="Next: Debug" icon="bug" href="/v7/debugging-with-screenshots">
|
|
148
|
+
Use screenshots and run output to see exactly what your test saw and pinpoint failures.
|
|
149
|
+
</Card>
|
package/docs/v7/provision.mdx
CHANGED
|
@@ -16,10 +16,6 @@ Access provision methods via `testdriver.provision.*`:
|
|
|
16
16
|
await testdriver.provision.chrome({ url: 'https://example.com' });
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
<Note>
|
|
20
|
-
When `reconnect: true` is set on the client, **all provision methods are skipped** since the application is assumed to already be running.
|
|
21
|
-
</Note>
|
|
22
|
-
|
|
23
19
|
## Methods
|
|
24
20
|
|
|
25
21
|
### chrome()
|
|
@@ -236,22 +232,6 @@ await testdriver.provision.dashcam({
|
|
|
236
232
|
});
|
|
237
233
|
```
|
|
238
234
|
|
|
239
|
-
## Reconnect Behavior
|
|
240
|
-
|
|
241
|
-
When `reconnect: true` is set on the client, all provision methods are wrapped in a Proxy that intercepts calls and skips them silently. This is because when reconnecting to an existing sandbox, the applications are already running.
|
|
242
|
-
|
|
243
|
-
```javascript
|
|
244
|
-
const testdriver = new TestDriver({
|
|
245
|
-
reconnect: true,
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
await testdriver.ready();
|
|
249
|
-
|
|
250
|
-
// These calls are silently skipped:
|
|
251
|
-
await testdriver.provision.chrome({ url: 'https://example.com' });
|
|
252
|
-
await testdriver.provision.dashcam();
|
|
253
|
-
```
|
|
254
|
-
|
|
255
235
|
## Types
|
|
256
236
|
|
|
257
237
|
```typescript
|