@testdriverai/agent 7.11.229-canary → 7.11.231-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.
Files changed (100) hide show
  1. package/docs/_data/examples-manifest.json +16 -16
  2. package/docs/_scripts/generate-examples.js +38 -45
  3. package/docs/agent.mdx +174 -93
  4. package/docs/assert.mdx +73 -269
  5. package/docs/aws-setup.mdx +196 -314
  6. package/docs/bring-your-own-machine.mdx +139 -206
  7. package/docs/cache.mdx +144 -151
  8. package/docs/caching.mdx +99 -89
  9. package/docs/captcha.mdx +126 -111
  10. package/docs/ci-cd.mdx +154 -543
  11. package/docs/click.mdx +74 -229
  12. package/docs/client.mdx +177 -231
  13. package/docs/copilot/auto-healing.mdx +86 -370
  14. package/docs/copilot/running-tests.mdx +121 -930
  15. package/docs/customizing-devices.mdx +74 -251
  16. package/docs/dashcam.mdx +72 -405
  17. package/docs/debugging-with-screenshots.mdx +105 -371
  18. package/docs/docs.json +75 -18
  19. package/docs/double-click.mdx +48 -68
  20. package/docs/errors.mdx +102 -176
  21. package/docs/events.mdx +170 -327
  22. package/docs/examples/{hover-text-with-description.mdx → add-to-cart.mdx} +30 -35
  23. package/docs/examples/assert.mdx +28 -41
  24. package/docs/examples/click-button.mdx +71 -0
  25. package/docs/examples/{hover-image.mdx → click-icon.mdx} +32 -28
  26. package/docs/examples/element-not-found.mdx +27 -26
  27. package/docs/examples/findall-coffee-icons.mdx +28 -32
  28. package/docs/examples/installer.mdx +61 -25
  29. package/docs/examples/launch-vscode-linux.mdx +28 -51
  30. package/docs/examples/navigate-and-scroll.mdx +82 -0
  31. package/docs/examples/parse.mdx +24 -28
  32. package/docs/examples/press-keys.mdx +28 -25
  33. package/docs/examples/scroll.mdx +25 -27
  34. package/docs/examples/type.mdx +26 -21
  35. package/docs/exec.mdx +92 -256
  36. package/docs/extract.mdx +69 -170
  37. package/docs/find.mdx +140 -736
  38. package/docs/focus-application.mdx +69 -246
  39. package/docs/generating-tests.mdx +103 -137
  40. package/docs/guide/best-practices-polling.mdx +65 -141
  41. package/docs/hosted.mdx +80 -144
  42. package/docs/hover.mdx +62 -235
  43. package/docs/locating-elements.mdx +74 -369
  44. package/docs/making-assertions.mdx +116 -74
  45. package/docs/mcp-setup.mdx +80 -63
  46. package/docs/mouse-down.mdx +48 -125
  47. package/docs/mouse-up.mdx +47 -129
  48. package/docs/options.mdx +75 -48
  49. package/docs/parse.mdx +95 -184
  50. package/docs/performing-actions.mdx +104 -94
  51. package/docs/press-keys.mdx +59 -299
  52. package/docs/provision.mdx +137 -182
  53. package/docs/quickstart-claude.mdx +85 -0
  54. package/docs/quickstart-github.mdx +62 -32
  55. package/docs/quickstart-manual.mdx +60 -33
  56. package/docs/quickstart-vscode.mdx +97 -0
  57. package/docs/quickstart.mdx +25 -9
  58. package/docs/redraw.mdx +101 -165
  59. package/docs/reusable-code.mdx +97 -200
  60. package/docs/right-click.mdx +47 -89
  61. package/docs/screenshot.mdx +47 -201
  62. package/docs/screenshots.mdx +87 -137
  63. package/docs/scroll.mdx +71 -154
  64. package/docs/secrets.mdx +96 -91
  65. package/docs/self-hosted.mdx +83 -142
  66. package/docs/snippets/enterprise.mdx +15 -0
  67. package/docs/styles.css +68 -0
  68. package/docs/test-results-json.mdx +167 -204
  69. package/docs/type.mdx +56 -304
  70. package/docs/variables.mdx +121 -81
  71. package/docs/wait.mdx +33 -31
  72. package/docs/what-is-testdriver.mdx +80 -32
  73. package/examples/{hover-text-with-description.test.mjs → add-to-cart.test.mjs} +4 -5
  74. package/examples/assert.test.mjs +3 -20
  75. package/examples/{hover-text.test.mjs → click-button.test.mjs} +3 -4
  76. package/examples/{hover-image.test.mjs → click-icon.test.mjs} +5 -6
  77. package/examples/element-not-found.test.mjs +3 -5
  78. package/examples/findall-coffee-icons.test.mjs +3 -3
  79. package/examples/installer.test.mjs +1 -1
  80. package/examples/launch-vscode-linux.test.mjs +6 -33
  81. package/examples/{scroll-keyboard.test.mjs → navigate-and-scroll.test.mjs} +4 -5
  82. package/examples/parse.test.mjs +1 -2
  83. package/examples/press-keys.test.mjs +4 -4
  84. package/examples/scroll.test.mjs +3 -6
  85. package/examples/type.test.mjs +5 -2
  86. package/lib/provision.js +6 -2
  87. package/package.json +1 -1
  88. package/sdk.d.ts +4 -2
  89. package/sdk.js +1 -1
  90. package/docs/claude-mcp-plugin.mdx +0 -244
  91. package/docs/elements.mdx +0 -606
  92. package/docs/examples/ai.mdx +0 -78
  93. package/docs/examples/captcha-api.mdx +0 -92
  94. package/docs/examples/chrome-extension.mdx +0 -156
  95. package/docs/examples/drag-and-drop.mdx +0 -100
  96. package/docs/examples/formatted-logging.mdx +0 -74
  97. package/docs/examples/hover-text.mdx +0 -70
  98. package/docs/examples/match-image.mdx +0 -97
  99. package/docs/examples/scroll-keyboard.mdx +0 -80
  100. package/docs/examples/scroll-until-text.mdx +0 -109
@@ -1,321 +1,144 @@
1
1
  ---
2
- title: "Customizing Devices"
3
- description: "Configure TestDriver sandbox options and environment settings"
2
+ title: "Customize the sandbox"
3
+ sidebarTitle: "Customizing devices"
4
+ description: "Choose the sandbox OS and resolution, preview mode, recording, and how long it stays alive."
4
5
  icon: "computer"
5
6
  ---
6
7
 
7
- ## TestDriver Options
8
+ import { EnterpriseBadge, EnterpriseCta } from '/snippets/enterprise.mdx';
8
9
 
9
- Configure the TestDriver behavior with options that you give to the `TestDriver()` function:
10
+ Every test runs in a sandbox: a fresh virtual machine. Pass options to `TestDriver(context, options)` to change it.
10
11
 
11
12
  ```javascript
12
13
  const testdriver = TestDriver(context, {
13
- // === Sandbox & Connection ===
14
- newSandbox: true, // Force creation of a new sandbox (default: true)
15
- reconnect: false, // Reconnect to last sandbox (default: false)
16
- keepAlive: 60000, // Keep sandbox alive after disconnect in ms (default: 60000)
17
- os: "linux", // 'linux' | 'windows' (default: 'linux')
18
- resolution: "1366x768", // Sandbox resolution (e.g., '1920x1080')
19
- ip: "203.0.113.42", // Direct IP for self-hosted sandbox
20
- sandboxAmi: "ami-1234", // Custom AMI ID (AWS deployments)
21
- sandboxInstance: "i3.metal", // EC2 instance type (AWS deployments)
22
-
23
- // === Preview & Debugging ===
24
- preview: "browser", // "browser" | "ide" | "none" (default: "browser")
25
- headless: false, // @deprecated - use preview: "none" instead
26
- debugOnFailure: false, // Keep sandbox alive on test failure for debugging
27
-
28
- // === Caching ===
29
- cache: true, // Enable element caching (default: true)
30
- // Or use advanced caching config:
31
- // cache: {
32
- // enabled: true,
33
- // thresholds: {
34
- // find: { screen: 0.05, element: 0.8 },
35
- // assert: 0.05
36
- // }
37
- // },
38
- cacheKey: "my-test", // Cache key for element finding operations
39
-
40
- // === Recording & Screenshots ===
41
- dashcam: true, // Enable/disable Dashcam video recording (default: true)
42
- autoScreenshots: true, // Capture screenshots before/after each command (default: false)
43
-
44
- // === AI Configuration ===
45
- ai: { // Global AI sampling configuration
46
- temperature: 0, // 0 = deterministic, higher = more creative
47
- top: {
48
- p: 0.9, // Top-P nucleus sampling (0-1)
49
- k: 40, // Top-K sampling (1 = most likely, 0 = disabled)
50
- },
51
- },
52
-
53
- // === Screen Change Detection ===
54
- redraw: true, // Enable redraw detection (default: true)
55
- // Or use advanced redraw config:
56
- // redraw: {
57
- // enabled: true,
58
- // thresholds: {
59
- // screen: 0.05, // Pixel diff threshold (0-1), false to disable
60
- // network: false, // Monitor network activity (default: false)
61
- // }
62
- // },
63
-
64
- // === Logging & Analytics ===
65
- logging: true, // Enable console logging output (default: true)
66
- analytics: true, // Enable analytics tracking (default: true)
67
-
68
- // === Advanced ===
69
- apiRoot: "https://...", // API endpoint URL (for self-hosted deployments)
70
- environment: {}, // Additional environment variables for the sandbox
14
+ os: 'windows',
15
+ preview: 'none',
16
+ keepAlive: 300000,
71
17
  });
72
18
  ```
73
19
 
74
- ### Preview Mode
20
+ This page covers the common changes. For every option and its default, see [Options](/options).
75
21
 
76
- Control how test execution is visualized. The `preview` option determines where the live debugger view opens:
22
+ ## Choose the operating system
77
23
 
78
- ```javascript
79
- const testdriver = TestDriver(context, {
80
- preview: "browser", // Opens in default browser (default)
81
- });
82
- ```
83
-
84
- | Value | Description |
85
- |-------|-------------|
86
- | `"browser"` | Opens debugger in default browser (default) |
87
- | `"ide"` | Opens preview in IDE panel (VSCode, Cursor - requires TestDriver extension) |
88
- | `"none"` | Headless mode, no visual preview |
89
-
90
- **IDE Preview**
91
-
92
- For the best development experience, use `preview: "ide"` with the TestDriver extension for VSCode or Cursor:
24
+ Sandboxes run Linux by default. Set `os` to run on Windows:
93
25
 
94
26
  ```javascript
95
- const testdriver = TestDriver(context, {
96
- preview: "ide", // Opens preview in IDE panel
97
- });
27
+ const testdriver = TestDriver(context, { os: 'windows' });
98
28
  ```
99
29
 
100
- **Headless Mode**
101
-
102
- Run tests without any visual preview. Useful for CI/CD pipelines:
103
-
104
- ```javascript
105
- const testdriver = TestDriver(context, {
106
- preview: "none", // No visual preview (headless)
107
- });
108
- ```
109
-
110
- <Note>
111
- The legacy `headless: true` option still works for backward compatibility and maps to `preview: "none"`.
112
- </Note>
113
-
114
- ### Debug on Failure
115
-
116
- Keep the sandbox alive when a test fails so you can reconnect and debug interactively. The sandbox ID is printed to the console along with instructions for reconnecting via MCP.
117
-
118
- ```javascript
119
- const testdriver = TestDriver(context, {
120
- debugOnFailure: true,
121
- });
122
- ```
30
+ <EnterpriseCta feature="Windows sandboxes" plural />
123
31
 
124
- ### IP Target
125
-
126
- If self-hosting TestDriver, use `ip` to specify the device IP. See [Run on Your Own Machine](/bring-your-own-machine) for details.
127
-
128
- ```javascript
129
- const testdriver = TestDriver(context, {
130
- ip: "203.0.113.42", // Your allowlisted IP
131
- });
132
- ```
133
-
134
- ### Operating System
135
-
136
- Set the `os` property to run tests on a specific operating system. Available options are `linux` (default) and `windows`.
137
-
138
- ```javascript
139
- const testdriver = TestDriver(context, {
140
- os: "windows", // Run on Windows sandbox
141
- });
142
- ```
143
-
144
- #### Using Environment Variables
145
-
146
- You can make the operating system configurable via environment variables. This requires adding code to read from `process.env` in your test:
147
-
148
- ```javascript
149
- const testdriver = TestDriver(context, {
150
- os: process.env.TD_OS || "linux", // Read from env, default to Linux
151
- });
152
- ```
153
-
154
- Then pass the variable when running tests:
32
+ The `TestDriver()` hook also reads the `TD_OS` environment variable when you don't pass `os`. That lets you run one suite on both systems without changing code:
155
33
 
156
34
  ```bash
157
- # Run tests on Windows
158
- TD_OS=windows vitest run
159
-
160
- # Run tests on Linux (default)
161
- TD_OS=linux vitest run
35
+ TD_OS=windows npx vitest run
162
36
  ```
163
37
 
164
- This pattern is useful for running the same test suite across multiple operating systems in CI/CD:
38
+ In GitHub Actions, run the suite once per OS with a matrix:
165
39
 
166
- ```yaml
167
- # Example GitHub Actions matrix
40
+ ```yaml .github/workflows/testdriver.yml
168
41
  strategy:
169
42
  matrix:
170
- os: [linux, windows]
43
+ td-os: [linux, windows]
171
44
  steps:
172
- - run: TD_OS=${{ matrix.os }} vitest run
45
+ # ...checkout, install, and authenticate steps
46
+ - name: Run tests on ${{ matrix.td-os }}
47
+ run: npx vitest run
48
+ env:
49
+ TD_OS: ${{ matrix.td-os }}
173
50
  ```
174
51
 
175
- ### Dashcam Recording
52
+ See [Run in CI/CD](/ci-cd) for the full workflow.
176
53
 
177
- Dashcam video recording is enabled by default. Disable it to skip recording:
54
+ ## Set the screen resolution
178
55
 
179
- ```javascript
180
- const testdriver = TestDriver(context, {
181
- dashcam: false,
182
- });
183
- ```
184
-
185
- ### Automatic Screenshots
186
-
187
- Screenshots are automatically captured before and after every command (click, type, find, assert, etc.) by default. Each screenshot filename includes the line number from your test file.
188
-
189
- Disable automatic screenshots:
56
+ The default resolution is `1366x768`. Set `resolution` to change it:
190
57
 
191
58
  ```javascript
192
- const testdriver = TestDriver(context, {
193
- autoScreenshots: false,
194
- });
59
+ const testdriver = TestDriver(context, { resolution: '1920x1080' });
195
60
  ```
196
61
 
197
- ### Caching
62
+ <EnterpriseCta feature="Custom screen resolution" />
198
63
 
199
- Element caching speeds up repeated `find()` and `assert()` calls. Enabled by default.
64
+ ## Choose how to watch the run
200
65
 
201
- ```javascript
202
- // Disable caching
203
- const testdriver = TestDriver(context, {
204
- cache: false,
205
- });
206
-
207
- // Advanced: custom thresholds
208
- const testdriver = TestDriver(context, {
209
- cache: {
210
- enabled: true,
211
- thresholds: {
212
- find: { screen: 0.05, element: 0.8 },
213
- assert: 0.05,
214
- },
215
- },
216
- cacheKey: "my-test",
217
- });
218
- ```
219
-
220
- ### Redraw Detection
66
+ `preview` sets where the live view of the sandbox opens:
221
67
 
222
- Redraw detection waits for the screen to stabilize before taking actions. Enabled by default.
68
+ - `"browser"` opens it in your default browser. This is the default.
69
+ - `"ide"` opens it in an editor panel. This needs the [TestDriver extension](/quickstart-vscode) for VS Code or Cursor.
70
+ - `"none"` turns the live view off. Use this in CI.
223
71
 
224
72
  ```javascript
225
- // Disable redraw detection
226
73
  const testdriver = TestDriver(context, {
227
- redraw: false,
228
- });
229
-
230
- // Advanced: custom thresholds with network monitoring
231
- const testdriver = TestDriver(context, {
232
- redraw: {
233
- enabled: true,
234
- thresholds: {
235
- screen: 0.05,
236
- network: true,
237
- },
238
- },
74
+ preview: process.env.CI ? 'none' : 'browser',
239
75
  });
240
76
  ```
241
77
 
242
- ### AI Configuration
78
+ `headless: true` is deprecated. Use `preview: "none"` instead.
243
79
 
244
- Control how the AI model generates responses for `find()` verification and `assert()` calls:
80
+ ## Record the run
245
81
 
246
- ```javascript
247
- const testdriver = TestDriver(context, {
248
- ai: {
249
- temperature: 0, // 0 = deterministic
250
- top: { p: 0.9, k: 40 },
251
- },
252
- });
253
- ```
254
-
255
- ### Environment Variables
256
-
257
- Pass additional environment variables to the sandbox:
82
+ - **Video.** [Dashcam](/dashcam) records every test by default. Set `dashcam: false` to turn it off.
83
+ - **Screenshots.** Set `autoScreenshots: true` to save a screenshot before and after each command. They're off by default. See [Debug a failing test](/debugging-with-screenshots).
258
84
 
259
85
  ```javascript
260
86
  const testdriver = TestDriver(context, {
261
- environment: {
262
- MY_VAR: "value",
263
- DEBUG: "true",
264
- },
87
+ dashcam: false,
88
+ autoScreenshots: true,
265
89
  });
266
90
  ```
267
91
 
268
- ## Keepalive
92
+ ## Keep a sandbox alive
269
93
 
270
- By default, sandboxes stay alive for 60 seconds after disconnect. Customize this with `keepAlive`:
94
+ After a test ends, its sandbox keeps running for `keepAlive` milliseconds, so you can reconnect to it:
271
95
 
272
- ```javascript
273
- const testdriver = TestDriver(context, {
274
- keepAlive: 300000, // Keep sandbox alive for 5 minutes after test
275
- });
276
- ```
277
-
278
- Set to `0` to terminate immediately:
96
+ - The default is `60000` (60 seconds).
97
+ - Values above 30 minutes are capped at 30 minutes.
98
+ - `0` uses the default. There's no value that ends the sandbox immediately.
99
+ - A sandbox never runs longer than 2 hours in total.
279
100
 
280
101
  ```javascript
281
102
  const testdriver = TestDriver(context, {
282
- keepAlive: 0, // Terminate sandbox immediately on disconnect
103
+ keepAlive: 10 * 60 * 1000, // 10 minutes
283
104
  });
284
105
  ```
285
106
 
286
- ### Connecting to an Existing Sandbox
287
-
288
- Speed up test development by connecting to an existing sandbox instead of starting fresh each time. This lets you iterate quickly on failing steps without re-running the entire test from the beginning.
107
+ To reconnect from another test file, set `reconnect: true`. TestDriver reattaches to the last sandbox it used and skips `provision` calls, because the app is already open. See [Reuse a sandbox while you iterate](/copilot/running-tests#reuse-a-sandbox-while-you-iterate).
289
108
 
290
- Split your test into two files: one for known-good steps that set up the desired state, and another for work-in-progress steps you want to debug.
109
+ To attach to a specific sandbox, pass its id as `sandboxId`. Unlike `reconnect`, `sandboxId` alone still runs `provision` calls.
291
110
 
292
- ```javascript known-good.test.mjs
293
- const testdriver = TestDriver(context, {
294
- keepAlive: 60000, // Keep sandbox alive for 60 seconds after test
295
- });
296
- ```
111
+ ### Keep the sandbox when a test fails
297
112
 
298
- ```javascript work-in-progress.test.mjs
299
- // Second test file: experiment.test.mjs (run within keepAlive window)
300
- const testdriver = TestDriver(context, {
301
- keepAlive: 60000,
302
- });
113
+ Set `debugOnFailure: true` to keep the sandbox running when a test fails. TestDriver prints the sandbox id so you can connect to it and look around.
303
114
 
304
- await testdriver.connect({ sandboxId: "sandbox-abc123" });
115
+ ```javascript
116
+ const testdriver = TestDriver(context, { debugOnFailure: true });
305
117
  ```
306
118
 
307
- Then, you can run both tests in sequence:
119
+ ## Run on your own machine
308
120
 
309
- ```bash
310
- vitest run -t known-good.test.mjs -t work-in-progress.test.mjs
311
- ```
121
+ To run tests on a machine you manage, set `ip` to its address. See [Run on your own machine](/bring-your-own-machine).
312
122
 
313
- And as you make changes to `work-in-progress.test.mjs`, you can re-run just that file to quickly iterate on the failing steps.
123
+ <EnterpriseCta feature="Connecting to your own machines" />
314
124
 
315
- ```bash
316
- vitest run work-in-progress.test.mjs
125
+ ```javascript
126
+ const testdriver = TestDriver(context, { ip: '203.0.113.42' });
317
127
  ```
318
128
 
319
- <Warning>
320
- Connecting to the same machine only works if run within the `keepAlive` window of the previous test.
321
- </Warning>
129
+ ## Next steps
130
+
131
+ <CardGroup cols={2}>
132
+ <Card title="Options" icon="sliders" href="/options">
133
+ Every client option, with its default.
134
+ </Card>
135
+ <Card title="Client & connection" icon="plug" href="/client">
136
+ Create, connect, and disconnect a client.
137
+ </Card>
138
+ <Card title="Run tests" icon="play" href="/copilot/running-tests">
139
+ Run tests locally and reuse a sandbox.
140
+ </Card>
141
+ <Card title="Run in CI/CD" icon="code-branch" href="/ci-cd">
142
+ Run tests on every pull request.
143
+ </Card>
144
+ </CardGroup>