testdriverai 7.9.33-test → 7.9.34-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 (76) hide show
  1. package/ai/skills/testdriver:ai/SKILL.md +204 -0
  2. package/ai/skills/testdriver:assert/SKILL.md +315 -0
  3. package/ai/skills/testdriver:aws-setup/SKILL.md +448 -0
  4. package/ai/skills/testdriver:cache/SKILL.md +221 -0
  5. package/ai/skills/testdriver:caching/SKILL.md +124 -0
  6. package/ai/skills/testdriver:captcha/SKILL.md +158 -0
  7. package/ai/skills/testdriver:ci-cd/SKILL.md +602 -0
  8. package/ai/skills/testdriver:click/SKILL.md +286 -0
  9. package/ai/skills/testdriver:client/SKILL.md +477 -0
  10. package/ai/skills/testdriver:customizing-devices/SKILL.md +319 -0
  11. package/ai/skills/testdriver:dashcam/SKILL.md +451 -0
  12. package/ai/skills/testdriver:debugging-with-screenshots/SKILL.md +415 -0
  13. package/ai/skills/testdriver:device-config/SKILL.md +317 -0
  14. package/ai/skills/testdriver:double-click/SKILL.md +102 -0
  15. package/ai/skills/testdriver:elements/SKILL.md +605 -0
  16. package/ai/skills/testdriver:enterprise/SKILL.md +7 -0
  17. package/ai/skills/testdriver:errors/SKILL.md +246 -0
  18. package/ai/skills/testdriver:events/SKILL.md +356 -0
  19. package/ai/skills/testdriver:exec/SKILL.md +317 -0
  20. package/ai/skills/testdriver:find/SKILL.md +860 -0
  21. package/ai/skills/testdriver:focus-application/SKILL.md +293 -0
  22. package/ai/skills/testdriver:generating-tests/SKILL.md +36 -0
  23. package/ai/skills/testdriver:hosted/SKILL.md +156 -0
  24. package/ai/skills/testdriver:hover/SKILL.md +278 -0
  25. package/ai/skills/testdriver:locating-elements/SKILL.md +71 -0
  26. package/ai/skills/testdriver:making-assertions/SKILL.md +32 -0
  27. package/ai/skills/testdriver:mcp/SKILL.md +7 -0
  28. package/ai/skills/testdriver:mouse-down/SKILL.md +161 -0
  29. package/ai/skills/testdriver:mouse-up/SKILL.md +164 -0
  30. package/ai/skills/testdriver:parse/SKILL.md +236 -0
  31. package/ai/skills/testdriver:performing-actions/SKILL.md +53 -0
  32. package/ai/skills/testdriver:press-keys/SKILL.md +348 -0
  33. package/ai/skills/testdriver:provision/SKILL.md +331 -0
  34. package/ai/skills/testdriver:quickstart/SKILL.md +172 -0
  35. package/ai/skills/testdriver:redraw/SKILL.md +214 -0
  36. package/ai/skills/testdriver:reusable-code/SKILL.md +249 -0
  37. package/ai/skills/testdriver:right-click/SKILL.md +123 -0
  38. package/ai/skills/testdriver:running-tests/SKILL.md +185 -0
  39. package/ai/skills/testdriver:screenshot/SKILL.md +248 -0
  40. package/ai/skills/testdriver:screenshots/SKILL.md +184 -0
  41. package/ai/skills/testdriver:scroll/SKILL.md +205 -0
  42. package/ai/skills/testdriver:secrets/SKILL.md +115 -0
  43. package/ai/skills/testdriver:self-hosted/SKILL.md +147 -0
  44. package/ai/skills/testdriver:test-results-json/SKILL.md +257 -0
  45. package/ai/skills/testdriver:testdriver/SKILL.md +624 -0
  46. package/ai/skills/testdriver:type/SKILL.md +357 -0
  47. package/ai/skills/testdriver:variables/SKILL.md +111 -0
  48. package/ai/skills/testdriver:wait/SKILL.md +50 -0
  49. package/ai/skills/testdriver:waiting-for-elements/SKILL.md +90 -0
  50. package/ai/skills/testdriver:what-is-testdriver/SKILL.md +54 -0
  51. package/docs/_data/examples-manifest.json +42 -42
  52. package/docs/v7/debugging-with-screenshots.mdx +14 -0
  53. package/docs/v7/examples/ai.mdx +1 -1
  54. package/docs/v7/examples/assert.mdx +1 -1
  55. package/docs/v7/examples/chrome-extension.mdx +2 -2
  56. package/docs/v7/examples/element-not-found.mdx +1 -1
  57. package/docs/v7/examples/exec-output.mdx +1 -1
  58. package/docs/v7/examples/exec-pwsh.mdx +1 -1
  59. package/docs/v7/examples/findall-coffee-icons.mdx +1 -1
  60. package/docs/v7/examples/focus-window.mdx +1 -1
  61. package/docs/v7/examples/hover-image.mdx +1 -1
  62. package/docs/v7/examples/hover-text-with-description.mdx +1 -1
  63. package/docs/v7/examples/hover-text.mdx +1 -1
  64. package/docs/v7/examples/installer.mdx +1 -1
  65. package/docs/v7/examples/launch-vscode-linux.mdx +1 -1
  66. package/docs/v7/examples/parse.mdx +1 -1
  67. package/docs/v7/examples/press-keys.mdx +1 -1
  68. package/docs/v7/examples/prompt.mdx +1 -1
  69. package/docs/v7/examples/scroll-keyboard.mdx +1 -1
  70. package/docs/v7/examples/scroll-until-image.mdx +1 -1
  71. package/docs/v7/examples/scroll.mdx +1 -1
  72. package/docs/v7/examples/type.mdx +1 -1
  73. package/docs/v7/examples/windows-installer.mdx +1 -1
  74. package/docs/v7/find.mdx +33 -0
  75. package/package.json +1 -1
  76. package/setup/aws/spawn-runner.sh +24 -3
@@ -0,0 +1,477 @@
1
+ ---
2
+ name: testdriver:client
3
+ description: Initialize and configure the TestDriver SDK client
4
+ ---
5
+ <!-- Generated from client.mdx. DO NOT EDIT. -->
6
+
7
+ ## Overview
8
+
9
+ The `TestDriver` client is the main entry point for the SDK. It handles authentication, sandbox connection, and provides access to all testing methods.
10
+
11
+ ## Constructor
12
+
13
+ ```javascript
14
+ const testdriver = new TestDriver(apiKey, options)
15
+ ```
16
+
17
+ ### Parameters
18
+
19
+ <ParamField path="apiKey" type="string" required>
20
+ Your TestDriver API key from the [dashboard](https://console.testdriver.ai/team)
21
+ </ParamField>
22
+
23
+ <ParamField path="options" type="object">
24
+ Configuration options for the client
25
+
26
+ <Expandable title="properties">
27
+ <ParamField path="os" type="string" default="linux">
28
+ Operating system for the sandbox: `'windows'` or `'linux'`
29
+ </ParamField>
30
+
31
+ <ParamField path="resolution" type="string" default="1366x768">
32
+ Screen resolution for the sandbox (e.g., `'1920x1080'`, `'1366x768'`)
33
+ </ParamField>
34
+
35
+ <ParamField path="apiRoot" type="string">
36
+ API endpoint URL (typically only changed for self-hosted deployments)
37
+ </ParamField>
38
+
39
+ <ParamField path="analytics" type="boolean" default="true">
40
+ Enable or disable usage analytics
41
+ </ParamField>
42
+
43
+ <ParamField path="logging" type="boolean" default="true">
44
+ Enable or disable console logging
45
+ </ParamField>
46
+
47
+ <ParamField path="autoScreenshots" type="boolean" default="false">
48
+ Automatically capture screenshots before and after each command. Screenshots are saved to `.testdriver/screenshots/<test>/` with descriptive filenames that include the line number and action name. Format: `<seq>-<action>-<phase>-L<line>-<description>.png`
49
+ </ParamField>
50
+
51
+ <ParamField path="newSandbox" type="boolean" default="true">
52
+ Force creation of a new sandbox instead of reusing an existing one
53
+ </ParamField>
54
+
55
+ <ParamField path="reconnect" type="boolean" default="false">
56
+ Reconnect to the last used sandbox instead of creating a new one. When `true`, provision methods (`chrome`, `vscode`, `installer`, etc.) will be skipped since the application is already running. Throws error if no previous sandbox exists.
57
+ </ParamField>
58
+
59
+ <ParamField path="preview" type="string" default="browser">
60
+ Preview mode for live test visualization:
61
+ - `"browser"` — Opens debugger in default browser (default)
62
+ - `"ide"` — Opens preview in IDE panel (VSCode, Cursor - requires TestDriver extension)
63
+ - `"none"` — Headless mode, no visual preview
64
+ </ParamField>
65
+
66
+ <ParamField path="headless" type="boolean" default="false">
67
+ **Deprecated**: Use `preview: "none"` instead. Run in headless mode without opening the debugger.
68
+ </ParamField>
69
+
70
+ <ParamField path="debugOnFailure" type="boolean" default="false">
71
+ Keep the sandbox alive when a test fails so you can reconnect and debug interactively. The sandbox ID is printed to the console.
72
+ </ParamField>
73
+
74
+ <ParamField path="ip" type="string">
75
+ Direct IP address to connect to a running sandbox instance (for self-hosted deployments)
76
+ </ParamField>
77
+
78
+ <ParamField path="sandboxAmi" type="string">
79
+ Custom AMI ID for the sandbox instance (AWS deployments, e.g., `'ami-1234'`)
80
+ </ParamField>
81
+
82
+ <ParamField path="sandboxInstance" type="string">
83
+ EC2 instance type for the sandbox (AWS deployments, e.g., `'i3.metal'`)
84
+ </ParamField>
85
+
86
+ <ParamField path="cache" type="boolean | object" default="true">
87
+ Enable or disable element caching, or provide advanced threshold configuration.
88
+
89
+ <Expandable title="advanced config">
90
+ <ParamField path="enabled" type="boolean" default="true">
91
+ Enable or disable caching
92
+ </ParamField>
93
+
94
+ <ParamField path="thresholds" type="object">
95
+ Fine-tune cache matching
96
+
97
+ <Expandable title="properties">
98
+ <ParamField path="find" type="object">
99
+ Thresholds for `find()` operations
100
+
101
+ <Expandable title="properties">
102
+ <ParamField path="screen" type="number" default="0.05">
103
+ Pixel diff threshold for screen comparison (0-1). `0.05` = 5% diff allowed.
104
+ </ParamField>
105
+
106
+ <ParamField path="element" type="number" default="0.8">
107
+ OpenCV template match threshold for element matching (0-1). `0.8` = 80% correlation.
108
+ </ParamField>
109
+ </Expandable>
110
+ </ParamField>
111
+
112
+ <ParamField path="assert" type="number" default="0.05">
113
+ Pixel diff threshold for `assert()` operations (0-1). `0.05` = 5% diff allowed.
114
+ </ParamField>
115
+ </Expandable>
116
+ </ParamField>
117
+ </Expandable>
118
+ </ParamField>
119
+
120
+ <ParamField path="cacheKey" type="string">
121
+ Cache key for element finding operations. If provided, enables caching tied to this key.
122
+ </ParamField>
123
+
124
+ <ParamField path="dashcam" type="boolean" default="true">
125
+ Enable or disable Dashcam video recording
126
+ </ParamField>
127
+
128
+ <ParamField path="redraw" type="boolean | object" default="true">
129
+ Enable or disable screen-change (redraw) detection, or provide advanced configuration.
130
+
131
+ <Expandable title="advanced config">
132
+ <ParamField path="enabled" type="boolean" default="true">
133
+ Enable or disable redraw detection
134
+ </ParamField>
135
+
136
+ <ParamField path="thresholds" type="object">
137
+ Threshold configuration
138
+
139
+ <Expandable title="properties">
140
+ <ParamField path="screen" type="number | false" default="0.05">
141
+ Pixel diff threshold (0-1). Set to `false` to disable screen redraw detection.
142
+ </ParamField>
143
+
144
+ <ParamField path="network" type="boolean" default="false">
145
+ Enable or disable network activity monitoring
146
+ </ParamField>
147
+ </Expandable>
148
+ </ParamField>
149
+ </Expandable>
150
+ </ParamField>
151
+
152
+ <ParamField path="environment" type="object">
153
+ Additional environment variables to pass to the sandbox
154
+ </ParamField>
155
+
156
+ <ParamField path="ai" type="object">
157
+ Global AI sampling configuration. Controls how the AI model generates responses for `find()` verification and `assert()` calls. Can be overridden per call.
158
+
159
+ <Expandable title="properties">
160
+ <ParamField path="temperature" type="number">
161
+ Controls randomness in AI responses. `0` = deterministic (best for verification), higher values = more creative. Default: `0` for find verification, model default for assert.
162
+ </ParamField>
163
+
164
+ <ParamField path="top" type="object">
165
+ Nucleus and top-k sampling parameters
166
+
167
+ <Expandable title="properties">
168
+ <ParamField path="p" type="number">
169
+ Top-P (nucleus sampling). Limits token choices to the smallest set whose cumulative probability exceeds P. Lower values = more focused responses. Range: 0-1.
170
+ </ParamField>
171
+
172
+ <ParamField path="k" type="number">
173
+ Top-K sampling. Limits token choices to the top K most likely tokens. `1` = always pick the most likely token. `0` = disabled (consider all tokens).
174
+ </ParamField>
175
+ </Expandable>
176
+ </ParamField>
177
+ </Expandable>
178
+ </ParamField>
179
+ </Expandable>
180
+ </ParamField>
181
+
182
+ ### Example
183
+
184
+ ```javascript
185
+ import TestDriver from 'testdriverai';
186
+
187
+ // API key is automatically loaded from TD_API_KEY in .env
188
+ const testdriver = new TestDriver({
189
+ os: 'windows',
190
+ resolution: '1920x1080',
191
+ logging: true,
192
+ analytics: true
193
+ });
194
+
195
+ // With AI config for stricter verification
196
+ const testdriver = new TestDriver({
197
+ ai: { temperature: 0, top: { p: 0.9, k: 40 } }
198
+ });
199
+
200
+ // Or pass API key explicitly
201
+ const testdriver = new TestDriver('your-api-key', {
202
+ os: 'windows'
203
+ });
204
+ ```
205
+
206
+ ## Authentication
207
+
208
+ ### auth()
209
+
210
+ Authenticate with the TestDriver API.
211
+
212
+ ```javascript
213
+ await testdriver.auth()
214
+ ```
215
+
216
+ **Returns:** `Promise<string>` - Authentication token
217
+
218
+ **Example:**
219
+ ```javascript
220
+ await testdriver.auth();
221
+ ```
222
+
223
+ <Note>
224
+ You must call `auth()` before `connect()`. Most examples call both sequentially.
225
+ </Note>
226
+
227
+ ## Connection Management
228
+
229
+ ### connect()
230
+
231
+ Connect to a sandbox environment. This creates or reconnects to a virtual machine where your tests will run.
232
+
233
+ ```javascript
234
+ await testdriver.connect(options)
235
+ ```
236
+
237
+ #### Parameters
238
+
239
+ <ParamField path="options" type="object">
240
+ Connection options
241
+
242
+ <Expandable title="properties">
243
+ <ParamField path="newSandbox" type="boolean" default="false">
244
+ Force creation of a new sandbox instead of reusing an existing one
245
+ </ParamField>
246
+
247
+ <ParamField path="sandboxId" type="string">
248
+ Existing sandbox ID to reconnect to
249
+ </ParamField>
250
+
251
+ <ParamField path="ip" type="string">
252
+ Direct IP address to connect to (for self-hosted sandboxes)
253
+ </ParamField>
254
+
255
+ <ParamField path="sandboxAmi" type="string">
256
+ AMI to use for the sandbox (AWS deployments)
257
+ </ParamField>
258
+
259
+ <ParamField path="sandboxInstance" type="string">
260
+ Instance type for the sandbox (AWS deployments)
261
+ </ParamField>
262
+
263
+ <ParamField path="preview" type="string" default="browser">
264
+ Preview mode for live test visualization:
265
+ - `"browser"` - Opens debugger in default browser (default)
266
+ - `"ide"` - Opens preview in IDE panel (VSCode, Cursor - requires TestDriver extension)
267
+ - `"none"` - Headless mode, no visual preview
268
+ </ParamField>
269
+
270
+ <ParamField path="headless" type="boolean" default="false">
271
+ **Deprecated**: Use `preview: "none"` instead. Run in headless mode without opening the debugger.
272
+ </ParamField>
273
+
274
+ <ParamField path="keepAlive" type="number" default="60000">
275
+ Keep sandbox alive for the specified number of milliseconds after disconnect. Set to `0` to terminate immediately on disconnect. Useful for debugging or reconnecting to the same sandbox.
276
+ </ParamField>
277
+ </Expandable>
278
+ </ParamField>
279
+
280
+ **Returns:** `Promise&lt;Object&gt;` - Sandbox instance details including `instanceId`, `ip`, `vncPort`, etc.
281
+
282
+ #### Examples
283
+
284
+ **Basic connection:**
285
+ ```javascript
286
+ await testdriver.connect();
287
+ ```
288
+
289
+ **Reconnect to existing sandbox:**
290
+ ```javascript
291
+ const instance = await testdriver.connect({
292
+ sandboxId: 'existing-sandbox-id-123'
293
+ });
294
+ ```
295
+
296
+ **Self-hosted sandbox:**
297
+ ```javascript
298
+ await testdriver.connect({
299
+ ip: '192.168.1.100'
300
+ });
301
+ ```
302
+
303
+ ### disconnect()
304
+
305
+ Disconnect from the sandbox and clean up resources.
306
+
307
+ ```javascript
308
+ await testdriver.disconnect()
309
+ ```
310
+
311
+ **Returns:** `Promise<void>`
312
+
313
+ **Example:**
314
+ ```javascript
315
+ afterAll(async () => {
316
+ await testdriver.disconnect();
317
+ });
318
+ ```
319
+
320
+ ## Instance Information
321
+
322
+ ### getInstance()
323
+
324
+ Get the current sandbox instance details.
325
+
326
+ ```javascript
327
+ const instance = testdriver.getInstance()
328
+ ```
329
+
330
+ **Returns:** `Object | null` - Sandbox instance information
331
+
332
+ **Example:**
333
+ ```javascript
334
+ const instance = testdriver.getInstance();
335
+ console.log('Instance ID:', instance.instanceId);
336
+ console.log('IP Address:', instance.ip);
337
+ ```
338
+
339
+ ### getSessionId()
340
+
341
+ Get the current session ID for tracking and debugging.
342
+
343
+ ```javascript
344
+ const sessionId = testdriver.getSessionId()
345
+ ```
346
+
347
+ **Returns:** `string | null` - Session ID
348
+
349
+ **Example:**
350
+ ```javascript
351
+ const sessionId = testdriver.getSessionId();
352
+ console.log('Session:', sessionId);
353
+ ```
354
+
355
+ ## Logging & Events
356
+
357
+ ### setLogging()
358
+
359
+ Enable or disable console logging at runtime.
360
+
361
+ ```javascript
362
+ testdriver.setLogging(enabled)
363
+ ```
364
+
365
+ **Parameters:**
366
+ - `enabled` (boolean) - Whether to enable logging
367
+
368
+ **Example:**
369
+ ```javascript
370
+ // Disable logging for cleanup operations
371
+ testdriver.setLogging(false);
372
+ await testdriver.disconnect();
373
+ testdriver.setLogging(true);
374
+ ```
375
+
376
+ ### getEmitter()
377
+
378
+ Get the event emitter for custom event handling.
379
+
380
+ ```javascript
381
+ const emitter = testdriver.getEmitter()
382
+ ```
383
+
384
+ **Returns:** `EventEmitter2` - Event emitter instance
385
+
386
+ **Example:**
387
+ ```javascript
388
+ const emitter = testdriver.getEmitter();
389
+
390
+ emitter.on('command:start', (data) => {
391
+ console.log('Command started:', data);
392
+ });
393
+
394
+ emitter.on('command:success', (data) => {
395
+ console.log('Command succeeded:', data);
396
+ });
397
+
398
+ emitter.on('command:error', (error) => {
399
+ console.error('Command failed:', error);
400
+ });
401
+ ```
402
+
403
+ ## Complete Example
404
+
405
+ ```javascript
406
+ import { beforeAll, afterAll, describe, it } from 'vitest';
407
+ import TestDriver from 'testdriverai';
408
+
409
+ describe('My Test Suite', () => {
410
+ let testdriver;
411
+
412
+ beforeAll(async () => {
413
+ // Initialize client - API key loaded automatically from .env
414
+ testdriver = new TestDriver({
415
+ os: 'windows',
416
+ resolution: '1366x768',
417
+ logging: true
418
+ });
419
+
420
+ // Set up event listeners
421
+ const emitter = testdriver.getEmitter();
422
+ emitter.on('log:info', (msg) => console.log('[INFO]', msg));
423
+
424
+ // Authenticate and connect
425
+ await testdriver.auth();
426
+ const instance = await testdriver.connect();
427
+
428
+ console.log('Connected to sandbox:', instance.instanceId);
429
+ });
430
+
431
+ afterAll(async () => {
432
+ await testdriver.disconnect();
433
+ });
434
+
435
+ it('runs a test', async () => {
436
+ // Your test code here
437
+ });
438
+ });
439
+ ```
440
+
441
+ ## Best Practices
442
+
443
+ <AccordionGroup>
444
+ <Accordion title="Reuse sandboxes across tests">
445
+ Use `beforeAll`/`afterAll` to create one sandbox per test suite rather than per test. This significantly reduces execution time.
446
+ </Accordion>
447
+
448
+ <Accordion title="Handle connection errors gracefully">
449
+ Wrap `connect()` in a try-catch block to handle network issues or quota limits:
450
+
451
+ ```javascript
452
+ try {
453
+ await testdriver.connect();
454
+ } catch (error) {
455
+ console.error('Failed to connect:', error.message);
456
+ throw error;
457
+ }
458
+ ```
459
+ </Accordion>
460
+
461
+ <Accordion title="Always disconnect">
462
+ Use `afterAll` or try-finally blocks to ensure `disconnect()` is called even if tests fail. This prevents orphaned sandboxes.
463
+ </Accordion>
464
+
465
+ <Accordion title="Use environment variables for API keys">
466
+ Never hardcode API keys. The SDK automatically loads `TD_API_KEY` from your `.env` file:
467
+
468
+ ```bash .env
469
+ TD_API_KEY=your_api_key_here
470
+ ```
471
+
472
+ ```javascript
473
+ // API key is loaded automatically - no need to pass it!
474
+ const testdriver = new TestDriver();
475
+ ```
476
+ </Accordion>
477
+ </AccordionGroup>