@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.
Files changed (196) hide show
  1. package/.claude-plugin/marketplace.json +17 -0
  2. package/agent/index.js +116 -71
  3. package/agent/interface.js +13 -1
  4. package/agent/lib/commands.js +35 -15
  5. package/agent/lib/provision-commands.js +92 -11
  6. package/agent/lib/sandbox.js +263 -30
  7. package/agent/lib/sdk.js +16 -12
  8. package/agent/lib/system.js +107 -31
  9. package/ai/.claude-plugin/plugin.json +89 -4
  10. package/ai/agents/testdriver.md +4 -8
  11. package/ai/skills/testdriver-assert/SKILL.md +0 -1
  12. package/ai/skills/testdriver-aws-setup/SKILL.md +1 -1
  13. package/ai/skills/testdriver-caching/SKILL.md +13 -6
  14. package/ai/skills/testdriver-ci-cd/SKILL.md +57 -14
  15. package/ai/skills/testdriver-client/SKILL.md +10 -6
  16. package/ai/skills/testdriver-customizing-devices/SKILL.md +7 -5
  17. package/ai/skills/testdriver-dashcam/SKILL.md +36 -3
  18. package/ai/skills/testdriver-debugging-with-screenshots/SKILL.md +28 -4
  19. package/ai/skills/testdriver-device-config/SKILL.md +5 -5
  20. package/ai/skills/testdriver-find/SKILL.md +50 -11
  21. package/ai/skills/testdriver-generating-tests/SKILL.md +163 -8
  22. package/ai/skills/testdriver-hosted/SKILL.md +1 -1
  23. package/ai/skills/testdriver-machine-setup/SKILL.md +331 -0
  24. package/ai/skills/testdriver-making-assertions/SKILL.md +78 -2
  25. package/ai/skills/testdriver-mcp-workflow/SKILL.md +2 -2
  26. package/ai/skills/testdriver-parse/SKILL.md +1 -1
  27. package/ai/skills/testdriver-performing-actions/SKILL.md +97 -3
  28. package/ai/skills/testdriver-provision/SKILL.md +0 -20
  29. package/ai/skills/testdriver-quickstart/SKILL.md +299 -21
  30. package/ai/skills/testdriver-reusable-code/SKILL.md +3 -3
  31. package/ai/skills/testdriver-running-tests/SKILL.md +1 -1
  32. package/ai/skills/testdriver-screenshot/SKILL.md +5 -5
  33. package/ai/skills/testdriver-scroll/SKILL.md +30 -160
  34. package/ai/skills/testdriver-test-writer/SKILL.md +3 -5
  35. package/ai/skills/testdriver-testdriver/SKILL.md +3 -7
  36. package/ai/skills/testdriver-wait/SKILL.md +1 -1
  37. package/{docs/v7/ai.mdx → ai/skills/testdriver:ai/SKILL.md} +3 -4
  38. package/ai/skills/testdriver:assert/SKILL.md +315 -0
  39. package/ai/skills/testdriver:aws-setup/SKILL.md +448 -0
  40. package/ai/skills/testdriver:cache/SKILL.md +221 -0
  41. package/ai/skills/testdriver:caching/SKILL.md +124 -0
  42. package/ai/skills/testdriver:captcha/SKILL.md +158 -0
  43. package/ai/skills/testdriver:ci-cd/SKILL.md +659 -0
  44. package/ai/skills/testdriver:click/SKILL.md +286 -0
  45. package/ai/skills/testdriver:client/SKILL.md +477 -0
  46. package/ai/skills/testdriver:customizing-devices/SKILL.md +319 -0
  47. package/ai/skills/testdriver:dashcam/SKILL.md +451 -0
  48. package/ai/skills/testdriver:debugging-with-screenshots/SKILL.md +415 -0
  49. package/{docs/v7/device-config.mdx → ai/skills/testdriver:device-config/SKILL.md} +8 -8
  50. package/ai/skills/testdriver:double-click/SKILL.md +102 -0
  51. package/ai/skills/testdriver:elements/SKILL.md +605 -0
  52. package/ai/skills/testdriver:enterprise/SKILL.md +7 -0
  53. package/ai/skills/testdriver:errors/SKILL.md +246 -0
  54. package/ai/skills/testdriver:events/SKILL.md +356 -0
  55. package/ai/skills/testdriver:exec/SKILL.md +317 -0
  56. package/ai/skills/testdriver:find/SKILL.md +860 -0
  57. package/ai/skills/testdriver:focus-application/SKILL.md +293 -0
  58. package/ai/skills/testdriver:generating-tests/SKILL.md +25 -0
  59. package/ai/skills/testdriver:hosted/SKILL.md +156 -0
  60. package/ai/skills/testdriver:hover/SKILL.md +278 -0
  61. package/{docs/v7/locating-elements.mdx → ai/skills/testdriver:locating-elements/SKILL.md} +3 -3
  62. package/ai/skills/testdriver:making-assertions/SKILL.md +32 -0
  63. package/ai/skills/testdriver:mcp/SKILL.md +7 -0
  64. package/ai/skills/testdriver:mouse-down/SKILL.md +161 -0
  65. package/ai/skills/testdriver:mouse-up/SKILL.md +164 -0
  66. package/ai/skills/testdriver:parse/SKILL.md +236 -0
  67. package/ai/skills/testdriver:performing-actions/SKILL.md +53 -0
  68. package/ai/skills/testdriver:press-keys/SKILL.md +348 -0
  69. package/ai/skills/testdriver:provision/SKILL.md +331 -0
  70. package/ai/skills/testdriver:quickstart/SKILL.md +172 -0
  71. package/ai/skills/testdriver:redraw/SKILL.md +214 -0
  72. package/ai/skills/testdriver:reusable-code/SKILL.md +249 -0
  73. package/ai/skills/testdriver:right-click/SKILL.md +123 -0
  74. package/{docs/v7/running-tests.mdx → ai/skills/testdriver:running-tests/SKILL.md} +4 -4
  75. package/ai/skills/testdriver:screenshot/SKILL.md +248 -0
  76. package/ai/skills/testdriver:screenshots/SKILL.md +184 -0
  77. package/ai/skills/testdriver:scroll/SKILL.md +205 -0
  78. package/ai/skills/testdriver:secrets/SKILL.md +115 -0
  79. package/ai/skills/testdriver:self-hosted/SKILL.md +147 -0
  80. package/ai/skills/testdriver:test-results-json/SKILL.md +257 -0
  81. package/ai/skills/testdriver:testdriver/SKILL.md +624 -0
  82. package/ai/skills/testdriver:type/SKILL.md +357 -0
  83. package/ai/skills/testdriver:variables/SKILL.md +111 -0
  84. package/ai/skills/testdriver:wait/SKILL.md +50 -0
  85. package/{docs/v7/waiting-for-elements.mdx → ai/skills/testdriver:waiting-for-elements/SKILL.md} +3 -3
  86. package/ai/skills/testdriver:what-is-testdriver/SKILL.md +54 -0
  87. package/debugger/index.html +12 -0
  88. package/docs/_data/examples-manifest.json +54 -46
  89. package/docs/_data/examples-manifest.schema.json +12 -2
  90. package/docs/_scripts/extract-example-urls.js +21 -3
  91. package/docs/_scripts/generate-examples.js +64 -16
  92. package/docs/changelog.mdx +29 -2
  93. package/docs/claude-mcp-plugin.mdx +65 -18
  94. package/docs/docs.json +16 -33
  95. package/docs/snippets/tests/scroll-yaml.mdx +2 -2
  96. package/docs/v6/commands/scroll-until-image.mdx +1 -1
  97. package/docs/v6/commands/scroll-until-text.mdx +2 -2
  98. package/docs/v6/commands/scroll.mdx +2 -2
  99. package/docs/v7/_drafts/agents.mdx +0 -4
  100. package/docs/v7/_drafts/best-practices.mdx +0 -12
  101. package/docs/v7/_drafts/commands/scroll-until-image.mdx +1 -1
  102. package/docs/v7/_drafts/commands/scroll-until-text.mdx +2 -2
  103. package/docs/v7/_drafts/commands/scroll.mdx +1 -1
  104. package/docs/v7/_drafts/configuration.mdx +0 -12
  105. package/docs/v7/_drafts/faq.mdx +2 -10
  106. package/docs/v7/_drafts/readme.mdx +0 -1
  107. package/docs/v7/_drafts/troubleshooting.mdx +1 -4
  108. package/docs/v7/assert.mdx +0 -1
  109. package/docs/v7/aws-setup.mdx +1 -1
  110. package/docs/v7/caching.mdx +14 -10
  111. package/docs/v7/ci-cd.mdx +98 -14
  112. package/docs/v7/client.mdx +10 -6
  113. package/docs/v7/copilot/auto-healing.mdx +167 -18
  114. package/docs/v7/copilot/running-tests.mdx +915 -54
  115. package/docs/v7/customizing-devices.mdx +7 -5
  116. package/docs/v7/dashcam.mdx +36 -3
  117. package/docs/v7/debugging-with-screenshots.mdx +31 -7
  118. package/docs/v7/examples/ai.mdx +13 -8
  119. package/docs/v7/examples/assert.mdx +1 -1
  120. package/docs/v7/examples/chrome-extension.mdx +30 -13
  121. package/docs/v7/examples/element-not-found.mdx +1 -1
  122. package/docs/v7/examples/findall-coffee-icons.mdx +3 -2
  123. package/docs/v7/examples/formatted-logging.mdx +74 -0
  124. package/docs/v7/examples/hover-image.mdx +1 -1
  125. package/docs/v7/examples/hover-text-with-description.mdx +2 -2
  126. package/docs/v7/examples/hover-text.mdx +1 -1
  127. package/docs/v7/examples/installer.mdx +1 -1
  128. package/docs/v7/examples/launch-vscode-linux.mdx +27 -27
  129. package/docs/v7/examples/match-image.mdx +1 -1
  130. package/docs/v7/examples/parse.mdx +3 -2
  131. package/docs/v7/examples/press-keys.mdx +2 -2
  132. package/docs/v7/examples/scroll-keyboard.mdx +2 -2
  133. package/docs/v7/examples/scroll-until-text.mdx +1 -1
  134. package/docs/v7/examples/scroll.mdx +1 -1
  135. package/docs/v7/examples/type.mdx +1 -1
  136. package/docs/v7/find.mdx +50 -11
  137. package/docs/v7/generating-tests.mdx +166 -10
  138. package/docs/v7/hosted.mdx +1 -1
  139. package/docs/v7/making-assertions.mdx +81 -4
  140. package/docs/v7/parse.mdx +1 -1
  141. package/docs/v7/performing-actions.mdx +100 -5
  142. package/docs/v7/provision.mdx +0 -20
  143. package/docs/v7/quickstart.mdx +299 -21
  144. package/docs/v7/reusable-code.mdx +3 -3
  145. package/docs/v7/screenshot.mdx +5 -5
  146. package/docs/v7/scroll.mdx +30 -160
  147. package/docs/v7/wait.mdx +1 -1
  148. package/examples/chrome-extension.test.mjs +29 -12
  149. package/examples/config.mjs +1 -1
  150. package/examples/launch-vscode-linux.test.mjs +25 -25
  151. package/interfaces/cli/commands/init.js +84 -2
  152. package/interfaces/vitest-plugin.mjs +51 -61
  153. package/lib/core/Dashcam.js +43 -2
  154. package/lib/core/index.d.ts +13 -1
  155. package/lib/github-comment.mjs +11 -5
  156. package/lib/init-project.js +98 -44
  157. package/lib/install-clients.js +470 -0
  158. package/lib/provision.js +749 -0
  159. package/lib/resolve-channel.js +2 -2
  160. package/lib/sentry.js +15 -2
  161. package/lib/vitest/hooks.mjs +44 -34
  162. package/mcp-server/README.md +32 -0
  163. package/mcp-server/dist/core/actions.d.ts +176 -0
  164. package/mcp-server/dist/core/actions.js +753 -0
  165. package/mcp-server/dist/env-utils.d.ts +45 -0
  166. package/mcp-server/dist/env-utils.js +63 -0
  167. package/mcp-server/dist/provision-types.d.ts +6 -2
  168. package/mcp-server/dist/provision-types.js +3 -1
  169. package/mcp-server/dist/server.mjs +449 -751
  170. package/mcp-server/package-lock.json +384 -1
  171. package/mcp-server/package.json +5 -2
  172. package/mcp-server/src/core/actions.ts +912 -0
  173. package/mcp-server/src/env-utils.test.ts +82 -0
  174. package/mcp-server/src/env-utils.ts +77 -0
  175. package/mcp-server/src/provision-types.ts +4 -1
  176. package/mcp-server/src/server.ts +533 -954
  177. package/mcp-server/tsconfig.json +1 -1
  178. package/mcp-server/vitest.config.ts +7 -0
  179. package/package.json +15 -3
  180. package/sdk.d.ts +11 -9
  181. package/sdk.js +116 -746
  182. package/setup/aws/spawn-runner.sh +24 -3
  183. package/docs/v7/_drafts/caching-ai.mdx +0 -215
  184. package/docs/v7/_drafts/caching.mdx +0 -366
  185. package/docs/v7/_drafts/prompt-cache.mdx +0 -200
  186. package/docs/v7/copilot/creating-tests.mdx +0 -156
  187. package/docs/v7/copilot/github.mdx +0 -143
  188. package/docs/v7/copilot/setup.mdx +0 -143
  189. package/docs/v7/examples/exec-output.mdx +0 -84
  190. package/docs/v7/examples/exec-pwsh.mdx +0 -82
  191. package/docs/v7/examples/focus-window.mdx +0 -61
  192. package/docs/v7/examples/scroll-until-image.mdx +0 -82
  193. package/docs/v7/examples/windows-installer.mdx +0 -95
  194. package/examples/formatted-logging.test.mjs +0 -27
  195. package/examples/match-image.test.mjs +0 -55
  196. 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={true}>
54
- Two-phase zoom mode for better precision in crowded UIs with many similar elements. Enabled by default.
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 **enabled by default**. It uses a two-phase approach for better precision when locating elements, especially in crowded UIs with many similar elements.
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 disable zoom for a specific find call, pass `zoom: false`:
344
+ To enable zoom for a specific find call, pass `zoom: true`:
341
345
 
342
346
  ```javascript
343
- // Zoom is on by default no option needed
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
- // Disable zoom for a specific call if needed
348
- const largeButton = await testdriver.find('big hero button', { zoom: false });
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 disable zoom with `zoom: false` when:
362
- - Targeting large, isolated elements where the extra precision isn't needed
363
- - You want to speed up find calls in simple UIs
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: "Generating Tests"
3
- description: "Use AI coding agents and exploration mode to generate TestDriver tests"
4
- icon: "wand-magic-sparkles"
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
- ## AI Exploration Mode
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
- Within a test, the `ai()` method lets TestDriver autonomously figure out how to accomplish a task. It's useful for dynamic or unpredictable UIs where explicit actions may be difficult to define.
44
+ Describe what you want to test:
30
45
 
31
- ```javascript
32
- // Handle dynamic or unpredictable UI
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
- <Info>Explicit commands are preferred for production tests, as they are cheaper, faster, and more reliable.</Info>
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>
@@ -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 { TestDriver } from 'testdriverai/vitest';
80
+ import TestDriver from 'testdriverai/vitest';
81
81
 
82
82
  export default defineConfig({
83
83
  test: {
@@ -1,12 +1,83 @@
1
1
  ---
2
- title: "Making Assertions"
3
- description: "Verify application state with AI-powered assertions"
4
- icon: "check-double"
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/lib/vitest/hooks.mjs";
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: "Performing Actions"
3
- description: "Click, type, hover, scroll and more with TestDriver"
4
- icon: "computer-mouse"
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
- ## Chaining Actions
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>
@@ -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