testdriverai 7.2.3 → 7.2.10

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 (142) hide show
  1. package/.github/workflows/publish.yaml +15 -7
  2. package/.github/workflows/testdriver.yml +163 -0
  3. package/.testdriver/last-sandbox +7 -0
  4. package/agent/events.js +1 -0
  5. package/agent/index.js +99 -163
  6. package/agent/lib/sandbox.js +11 -1
  7. package/agents.md +393 -0
  8. package/bin/testdriverai.js +8 -0
  9. package/debug/01-table-initial.png +0 -0
  10. package/debug/02-after-ai-explore.png +0 -0
  11. package/debug/02-after-scroll.png +0 -0
  12. package/debugger/index.html +37 -0
  13. package/docs/docs.json +93 -125
  14. package/docs/v7/_drafts/architecture.mdx +1 -26
  15. package/docs/v7/_drafts/caching.mdx +2 -2
  16. package/docs/v7/{getting-started → _drafts}/installation.mdx +0 -66
  17. package/docs/v7/{features/coverage.mdx → _drafts/powerful.mdx} +1 -90
  18. package/docs/v7/_drafts/quick-start-test-recording.mdx +0 -1
  19. package/docs/v7/{features → _drafts}/scalable.mdx +126 -4
  20. package/docs/v7/_drafts/screenshot.mdx +155 -0
  21. package/docs/v7/_drafts/test-recording.mdx +0 -6
  22. package/docs/v7/_drafts/writing-tests.mdx +25 -0
  23. package/docs/v7/{api/act.mdx → ai.mdx} +28 -27
  24. package/docs/v7/{api/assert.mdx → assert.mdx} +3 -3
  25. package/docs/v7/aws-setup.mdx +338 -0
  26. package/docs/v7/caching.mdx +128 -0
  27. package/docs/v7/ci-cd.mdx +605 -0
  28. package/docs/v7/{api/click.mdx → click.mdx} +4 -4
  29. package/docs/v7/cloud.mdx +120 -0
  30. package/docs/v7/customizing-devices.mdx +129 -0
  31. package/docs/v7/{api/doubleClick.mdx → double-click.mdx} +5 -5
  32. package/docs/v7/enterprise.mdx +135 -0
  33. package/docs/v7/examples.mdx +5 -0
  34. package/docs/v7/{api/exec.mdx → exec.mdx} +3 -3
  35. package/docs/v7/{api/find.mdx → find.mdx} +17 -21
  36. package/docs/v7/{api/focusApplication.mdx → focus-application.mdx} +3 -3
  37. package/docs/v7/generating-tests.mdx +32 -0
  38. package/docs/v7/{api/hover.mdx → hover.mdx} +3 -3
  39. package/docs/v7/locating-elements.mdx +71 -0
  40. package/docs/v7/making-assertions.mdx +32 -0
  41. package/docs/v7/{api/mouseDown.mdx → mouse-down.mdx} +7 -7
  42. package/docs/v7/{api/mouseUp.mdx → mouse-up.mdx} +8 -8
  43. package/docs/v7/performing-actions.mdx +51 -0
  44. package/docs/v7/{api/pressKeys.mdx → press-keys.mdx} +3 -3
  45. package/docs/v7/quickstart.mdx +162 -0
  46. package/docs/v7/reusable-code.mdx +240 -0
  47. package/docs/v7/{api/rightClick.mdx → right-click.mdx} +5 -5
  48. package/docs/v7/running-tests.mdx +181 -0
  49. package/docs/v7/{api/scroll.mdx → scroll.mdx} +3 -3
  50. package/docs/v7/secrets.mdx +115 -0
  51. package/docs/v7/self-hosted.mdx +66 -0
  52. package/docs/v7/{api/type.mdx → type.mdx} +3 -3
  53. package/docs/v7/variables.mdx +111 -0
  54. package/docs/v7/waiting-for-elements.mdx +66 -0
  55. package/docs/v7/what-is-testdriver.mdx +54 -0
  56. package/interfaces/cli/commands/init.js +33 -19
  57. package/interfaces/cli/lib/base.js +24 -0
  58. package/interfaces/cli.js +8 -1
  59. package/interfaces/logger.js +8 -3
  60. package/interfaces/vitest-plugin.mjs +16 -71
  61. package/lib/sentry.js +343 -0
  62. package/lib/vitest/hooks.mjs +81 -81
  63. package/package.json +4 -3
  64. package/sdk-log-formatter.js +41 -0
  65. package/sdk.d.ts +22 -9
  66. package/sdk.js +344 -100
  67. package/test/manual/reconnect-provision.test.mjs +49 -0
  68. package/test/manual/reconnect-signin.test.mjs +41 -0
  69. package/test/testdriver/act.test.mjs +30 -0
  70. package/test/testdriver/ai.test.mjs +30 -0
  71. package/test/testdriver/assert.test.mjs +1 -1
  72. package/test/testdriver/hover-text.test.mjs +1 -1
  73. package/test/testdriver/setup/testHelpers.mjs +8 -119
  74. package/test/testdriver/windows-installer.test.mjs +61 -0
  75. package/tests/example.test.js +33 -0
  76. package/tests/login.js +28 -0
  77. package/tests/table-sort-enrollments.test.mjs +72 -0
  78. package/tests/table-sort-experiment.test.mjs +42 -0
  79. package/tests/table-sort-setup.test.mjs +59 -0
  80. package/vitest.config.mjs +3 -1
  81. package/agent/lib/cache.js +0 -142
  82. package/docs/v7/api/assertions.mdx +0 -403
  83. package/docs/v7/features/ai-native.mdx +0 -413
  84. package/docs/v7/features/application-logs.mdx +0 -353
  85. package/docs/v7/features/browser-logs.mdx +0 -414
  86. package/docs/v7/features/cache-management.mdx +0 -402
  87. package/docs/v7/features/continuous-testing.mdx +0 -346
  88. package/docs/v7/features/data-driven-testing.mdx +0 -441
  89. package/docs/v7/features/easy-to-write.mdx +0 -280
  90. package/docs/v7/features/enterprise.mdx +0 -656
  91. package/docs/v7/features/fast.mdx +0 -406
  92. package/docs/v7/features/managed-sandboxes.mdx +0 -384
  93. package/docs/v7/features/network-monitoring.mdx +0 -568
  94. package/docs/v7/features/parallel-execution.mdx +0 -381
  95. package/docs/v7/features/powerful.mdx +0 -531
  96. package/docs/v7/features/sandbox-customization.mdx +0 -229
  97. package/docs/v7/features/stable.mdx +0 -473
  98. package/docs/v7/features/system-performance.mdx +0 -616
  99. package/docs/v7/features/test-analytics.mdx +0 -373
  100. package/docs/v7/features/test-cases.mdx +0 -393
  101. package/docs/v7/features/test-replays.mdx +0 -408
  102. package/docs/v7/features/test-reports.mdx +0 -308
  103. package/docs/v7/getting-started/debugging-tests.mdx +0 -382
  104. package/docs/v7/getting-started/quickstart.mdx +0 -90
  105. package/docs/v7/getting-started/running-tests.mdx +0 -173
  106. package/docs/v7/getting-started/setting-up-in-ci.mdx +0 -612
  107. package/docs/v7/getting-started/writing-tests.mdx +0 -534
  108. package/docs/v7/overview/what-is-testdriver.mdx +0 -386
  109. package/docs/v7/presets/chrome-extension.mdx +0 -248
  110. package/docs/v7/presets/chrome.mdx +0 -300
  111. package/docs/v7/presets/electron.mdx +0 -460
  112. package/docs/v7/presets/vscode.mdx +0 -417
  113. package/docs/v7/presets/webapp.mdx +0 -393
  114. /package/docs/v7/{commands → _drafts/commands}/assert.mdx +0 -0
  115. /package/docs/v7/{commands → _drafts/commands}/exec.mdx +0 -0
  116. /package/docs/v7/{commands → _drafts/commands}/focus-application.mdx +0 -0
  117. /package/docs/v7/{commands → _drafts/commands}/hover-image.mdx +0 -0
  118. /package/docs/v7/{commands → _drafts/commands}/hover-text.mdx +0 -0
  119. /package/docs/v7/{commands → _drafts/commands}/if.mdx +0 -0
  120. /package/docs/v7/{commands → _drafts/commands}/match-image.mdx +0 -0
  121. /package/docs/v7/{commands → _drafts/commands}/press-keys.mdx +0 -0
  122. /package/docs/v7/{commands → _drafts/commands}/remember.mdx +0 -0
  123. /package/docs/v7/{commands → _drafts/commands}/run.mdx +0 -0
  124. /package/docs/v7/{commands → _drafts/commands}/scroll-until-image.mdx +0 -0
  125. /package/docs/v7/{commands → _drafts/commands}/scroll-until-text.mdx +0 -0
  126. /package/docs/v7/{commands → _drafts/commands}/scroll.mdx +0 -0
  127. /package/docs/v7/{commands → _drafts/commands}/type.mdx +0 -0
  128. /package/docs/v7/{commands → _drafts/commands}/wait-for-image.mdx +0 -0
  129. /package/docs/v7/{commands → _drafts/commands}/wait-for-text.mdx +0 -0
  130. /package/docs/v7/{commands → _drafts/commands}/wait.mdx +0 -0
  131. /package/docs/v7/{getting-started → _drafts}/configuration.mdx +0 -0
  132. /package/docs/v7/{features → _drafts}/observable.mdx +0 -0
  133. /package/docs/v7/{platforms → _drafts/platforms}/linux.mdx +0 -0
  134. /package/docs/v7/{platforms → _drafts/platforms}/macos.mdx +0 -0
  135. /package/docs/v7/{platforms → _drafts/platforms}/windows.mdx +0 -0
  136. /package/docs/v7/{playwright.mdx → _drafts/playwright.mdx} +0 -0
  137. /package/docs/v7/{overview → _drafts}/readme.mdx +0 -0
  138. /package/docs/v7/{features → _drafts}/reports.mdx +0 -0
  139. /package/docs/v7/{api/client.mdx → client.mdx} +0 -0
  140. /package/docs/v7/{api/dashcam.mdx → dashcam.mdx} +0 -0
  141. /package/docs/v7/{api/elements.mdx → elements.mdx} +0 -0
  142. /package/docs/v7/{api/sandbox.mdx → sandbox.mdx} +0 -0
@@ -1,413 +0,0 @@
1
- ---
2
- title: "AI Test Generation"
3
- description: "Built specifically for AI agents and autonomous testing"
4
- icon: "robot"
5
- ---
6
-
7
- TestDriver is designed from the ground up to be used by AI agents, enabling autonomous test creation, execution, and debugging.
8
-
9
- ## AI Agent Support
10
-
11
- Complete guide for AI agents with autonomous operation patterns:
12
-
13
- <Card title="agents.md - AI Agent Guide" icon="book" href="/agents.md">
14
- Comprehensive documentation specifically for AI agents, including:
15
-
16
- - Quick setup and authentication
17
- - Provision methods (chrome, vscode, electron)
18
- - Core API methods with examples
19
- - Sandbox reconnection patterns
20
- - Debugging failed finds
21
- - Iterative selector refinement
22
- - Best practices for autonomous operation
23
- </Card>
24
-
25
- ```javascript
26
- // AI agents can autonomously write and run tests
27
- import { test } from 'vitest';
28
- import { chrome } from 'testdriverai/presets';
29
-
30
- test('ai-generated test', async (context) => {
31
- const { testdriver } = await chrome(context, {
32
- url: 'https://example.com'
33
- });
34
-
35
- await testdriver.find('More information link').click();
36
- await testdriver.assert('IANA page is visible');
37
- });
38
- ```
39
-
40
- ## Natural Language Everything
41
-
42
- AI-powered element location, assertions, and instructions:
43
-
44
- <Tabs>
45
- <Tab title="Element Location">
46
- ```javascript
47
- // Describe elements naturally
48
- await testdriver.find('submit button');
49
- await testdriver.find('email input in the login form');
50
- await testdriver.find('delete button in the top right corner');
51
- await testdriver.find('first product card in the grid');
52
- ```
53
- </Tab>
54
-
55
- <Tab title="Assertions">
56
- ```javascript
57
- // Assert application state naturally
58
- await testdriver.assert('the login page is displayed');
59
- await testdriver.assert('success message says "Welcome back"');
60
- await testdriver.assert('the form is empty');
61
- await testdriver.assert('the button is blue and enabled');
62
- await testdriver.assert('loading spinner is not visible');
63
- ```
64
- </Tab>
65
-
66
- <Tab title="Instructions">
67
- ```javascript
68
- // Complex interactions described naturally
69
- await testdriver.find('Products menu').hover();
70
- await testdriver.find('Laptops submenu item in the Products dropdown').click();
71
- await testdriver.find('Sort by dropdown').click();
72
- await testdriver.find('Price: Low to High option').click();
73
- ```
74
- </Tab>
75
- </Tabs>
76
-
77
- ## Test Generation with Claude Code
78
-
79
- Feed natural language requirements directly to Claude Code to generate complete test suites:
80
-
81
- <Steps>
82
-
83
- <Step title="Ask Claude Code to Generate Tests">
84
- Provide the requirements to Claude Code with context about your testing setup:
85
-
86
- ```text
87
- Generate a TestDriver test using Vitest for these requirements:
88
-
89
- Test the login flow:
90
- 1. Navigate to login page
91
- 2. Enter valid credentials
92
- 3. Click submit
93
- 4. Verify dashboard appears
94
-
95
- Use the chrome preset and target https://myapp.com/login
96
- ```
97
- </Step>
98
-
99
- <Step title="Claude Generates Complete Tests">
100
- Claude Code will create production-ready test files:
101
-
102
- ```javascript
103
- import { test } from 'vitest';
104
- import { chrome } from 'testdriverai/presets';
105
-
106
- test('user can login', async (context) => {
107
- const { testdriver } = await chrome(context, {
108
- url: 'https://myapp.com/login'
109
- });
110
-
111
- await testdriver.find('email input').type('user@example.com');
112
- await testdriver.find('password input').type('password', { secret: true });
113
- await testdriver.find('Login button').click();
114
-
115
- await testdriver.assert('Dashboard is visible');
116
- });
117
- ```
118
- </Step>
119
-
120
- <Step title="Run Tests and Iterate">
121
- Ask Claude Code to run the tests and refine based on results:
122
-
123
- ```text
124
- Run these tests and fix any failures. Then add tests for:
125
- - Invalid credentials
126
- - Empty form submission
127
- - Password visibility toggle
128
- ```
129
-
130
- Claude will execute the tests, analyze failures, and automatically refine the test code.
131
- </Step>
132
- </Steps>
133
-
134
- <Tip>
135
- Claude Code understands TestDriver's natural language API and will automatically use appropriate selectors, assertions, and best practices like `secret: true` for passwords.
136
- </Tip>
137
-
138
- ## Sandbox Reconnection
139
-
140
- AI agents can reconnect to sandboxes for debugging:
141
-
142
- ```javascript
143
- // Initial test attempt
144
- test('initial attempt', async () => {
145
- const testdriver = new TestDriver({
146
- apiKey: process.env.TD_API_KEY
147
- });
148
-
149
- const instance = await testdriver.connect();
150
- console.log('Sandbox ID:', instance.instanceId);
151
- // Save this ID for reconnection
152
-
153
- try {
154
- await testdriver.find('difficult selector').click();
155
- } catch (error) {
156
- console.error('Failed:', error);
157
- // Keep sandbox alive for debugging
158
- }
159
- });
160
-
161
- // Reconnect to same sandbox
162
- test('reconnect attempt', async () => {
163
- const testdriver = new TestDriver({
164
- apiKey: process.env.TD_API_KEY
165
- });
166
-
167
- // Manually specify the sandbox ID from previous test
168
- await testdriver.connect({
169
- sandboxId: 'your-sandbox-id-here',
170
- newSandbox: false
171
- });
172
-
173
- // Try alternative selector
174
- await testdriver.find('alternative selector').click();
175
-
176
- await testdriver.disconnect();
177
- });
178
- ```
179
-
180
- <Card title="Automatic Sandbox Tracking" icon="bookmark">
181
- TestDriver automatically saves the last sandbox ID to `~/.testdriverai-last-sandbox`. By default, `newSandbox: true`, so each connection creates a new sandbox. Set `newSandbox: false` and provide a `sandboxId` to reconnect to an existing sandbox.
182
- </Card>
183
-
184
- ## Error Analysis
185
-
186
- Rich error information for AI agents to analyze and adapt:
187
-
188
- ```javascript
189
- try {
190
- await testdriver.find('non-existent button').click();
191
- } catch (error) {
192
- // Rich error information for AI analysis
193
- console.log('Error type:', error.name); // 'ElementNotFoundError'
194
- console.log('Message:', error.message);
195
- console.log('Similarity score:', error.similarity); // 0.72
196
- console.log('Confidence:', error.confidence); // 0.81
197
- console.log('Debug screenshot:', error.debugScreenshot); // Base64
198
- console.log('Cache info:', error.cacheInfo);
199
- console.log('Attempted prompt:', error.prompt);
200
-
201
- // AI can analyze and adapt
202
- if (error.similarity > 0.7) {
203
- // Close match, try more specific selector
204
- await testdriver.find('blue submit button in bottom right').click();
205
- } else {
206
- // No close match, try completely different approach
207
- await testdriver.find('primary action button').click();
208
- }
209
- }
210
- ```
211
-
212
- ## MCP Integration (Coming Soon)
213
-
214
- Query test infrastructure using natural language:
215
-
216
- ```javascript
217
- // Future MCP interactivity
218
- await testdriver.mcp.query("What is the CPU usage of my app?");
219
- await testdriver.mcp.query("Show me memory leaks in the last test run");
220
- await testdriver.mcp.query("What tests are flakiest this week?");
221
- await testdriver.mcp.query("Compare performance between branches");
222
- ```
223
-
224
- <Note>
225
- MCP (Model Context Protocol) integration is planned for Q1 2025.
226
- </Note>
227
-
228
- ## AI-Powered Debugging
229
-
230
- TestDriver provides intelligent debugging assistance:
231
-
232
- <AccordionGroup>
233
- <Accordion title="Similarity Scoring">
234
- ```javascript
235
- // AI analyzes how close the match was
236
- try {
237
- await testdriver.find('submit button');
238
- } catch (error) {
239
- if (error.similarity > 0.8) {
240
- console.log('Very close match - likely wrong selector specificity');
241
- } else if (error.similarity > 0.5) {
242
- console.log('Partial match - element might be present but different');
243
- } else {
244
- console.log('No match - element likely not on screen');
245
- }
246
- }
247
- ```
248
- </Accordion>
249
-
250
- <Accordion title="Visual Debugging">
251
- ```javascript
252
- // Get debug screenshot for AI analysis
253
- try {
254
- await testdriver.find('button');
255
- } catch (error) {
256
- // AI can analyze the debug screenshot
257
- const screenshot = error.debugScreenshot; // Base64 image
258
- // Send to vision model for analysis
259
- const analysis = await visionModel.analyze(screenshot,
260
- "Why can't we find the submit button?"
261
- );
262
- }
263
- ```
264
- </Accordion>
265
-
266
- <Accordion title="Cache Diagnostics">
267
- ```javascript
268
- // Understand cache behavior
269
- try {
270
- await testdriver.find('element');
271
- } catch (error) {
272
- console.log('Cache info:', error.cacheInfo);
273
- // {
274
- // cacheKey: 'abc123',
275
- // cacheHit: false,
276
- // similarEntries: 3,
277
- // bestSimilarity: 0.87,
278
- // reason: 'threshold_not_met'
279
- // }
280
- }
281
- ```
282
- </Accordion>
283
- </AccordionGroup>
284
-
285
- ## Programmatic Control
286
-
287
- AI agents have full programmatic control:
288
-
289
- ```javascript
290
- // Dynamic test generation
291
- const testCases = [
292
- { email: 'user1@example.com', password: 'pass1', shouldSucceed: true },
293
- { email: 'invalid', password: 'pass2', shouldSucceed: false },
294
- { email: 'user3@example.com', password: 'wrong', shouldSucceed: false },
295
- ];
296
-
297
- for (const testCase of testCases) {
298
- test(`login with ${testCase.email}`, async (context) => {
299
- const { testdriver } = await chrome(context, { url });
300
-
301
- await testdriver.find('email input').type(testCase.email);
302
- await testdriver.find('password input').type(testCase.password, { secret: true });
303
- await testdriver.find('submit').click();
304
-
305
- if (testCase.shouldSucceed) {
306
- await testdriver.assert('dashboard is visible');
307
- } else {
308
- await testdriver.assert('error message is displayed');
309
- }
310
- });
311
- }
312
- ```
313
-
314
- ## Learning & Adaptation
315
-
316
- TestDriver learns from test executions:
317
-
318
- <Card title="AI Understanding of Your App" icon="brain">
319
- The cache system builds a visual understanding over time:
320
-
321
- - Element location patterns
322
- - UI component relationships
323
- - Common interaction flows
324
- - Stability characteristics
325
- - Performance baselines
326
-
327
- This enables:
328
- - Faster subsequent executions
329
- - Better error messages
330
- - Intelligent suggestions
331
- - Anomaly detection
332
- </Card>
333
-
334
- ## Best Practices for AI Agents
335
-
336
- <AccordionGroup>
337
- <Accordion title="1. Use Descriptive Selectors">
338
- ```javascript
339
- // ✅ Good - specific and contextual
340
- await testdriver.find('blue submit button below the login form');
341
-
342
- // ❌ Bad - too vague
343
- await testdriver.find('button');
344
- ```
345
- </Accordion>
346
-
347
- <Accordion title="2. Always Use secret: true for Passwords">
348
- ```javascript
349
- // ✅ Protected from logging
350
- await testdriver.type('MyPassword123', { secret: true });
351
-
352
- // ❌ Password will be logged
353
- await testdriver.type('MyPassword123');
354
- ```
355
- </Accordion>
356
-
357
- <Accordion title="3. Handle Errors Gracefully">
358
- ```javascript
359
- // ✅ Try alternative approaches
360
- try {
361
- await testdriver.find('optional element').click();
362
- } catch (error) {
363
- console.log('Element not found, trying alternative...');
364
- await testdriver.find('alternative element').click();
365
- }
366
- ```
367
- </Accordion>
368
-
369
- <Accordion title="4. Save Sandbox IDs">
370
- ```javascript
371
- // ✅ Enable reconnection
372
- const instance = await testdriver.connect();
373
- console.log('Sandbox ID:', instance.instanceId);
374
- // Save for debugging later
375
- ```
376
- </Accordion>
377
- </AccordionGroup>
378
-
379
- ## Learn More
380
-
381
- <CardGroup cols={2}>
382
- <Card
383
- title="AI Agent Guide"
384
- icon="robot"
385
- href="/agents.md"
386
- >
387
- Complete guide for AI agents
388
- </Card>
389
-
390
- <Card
391
- title="API Reference"
392
- icon="code"
393
- href="/v7/api/client"
394
- >
395
- Full API documentation
396
- </Card>
397
-
398
- <Card
399
- title="Error Handling"
400
- icon="triangle-exclamation"
401
- href="/v7/guides/error-handling"
402
- >
403
- Handle errors effectively
404
- </Card>
405
-
406
- <Card
407
- title="Debugging Guide"
408
- icon="bug"
409
- href="/v7/guides/debugging"
410
- >
411
- Debug failing tests
412
- </Card>
413
- </CardGroup>