@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,426 +1,160 @@
1
1
  ---
2
- title: "Debugging Tests"
3
- sidebarTitle: "Debugging Tests"
4
- description: "Diagnose failing tests with screenshots, replays, and logs"
2
+ title: "Debug a failing test"
3
+ sidebarTitle: "Debugging tests"
4
+ description: "Find out why a test failed from its replay and step-by-step screenshots."
5
5
  icon: "bug"
6
6
  ---
7
7
 
8
- ## Overview
8
+ When a test fails, look at what the sandbox showed instead of guessing from the error.
9
9
 
10
- When a test fails, debug it. Look at what happened. Do not guess. TestDriver captures screenshots, video replays, and logs while your test runs. Thus you can replay the moment of the failure. You do not need to look at a stack trace. TestDriver MCP gives commands to view and examine the screenshots that TestDriver saved during the test. This lets you debug quickly, develop tests, and compare, without a manual open of image files.
10
+ - Every run records a replay you can step through.
11
+ - With automatic screenshots on, TestDriver also saves an image before and after each `testdriver` method call, named after the line of code that ran it.
11
12
 
12
- <Note>
13
- **Automatic Screenshots (Default: Enabled)**: TestDriver captures screenshots automatically before and after each command. The screenshot name has the line number and the action. Thus it is easy to see which line of code made each screenshot. For example: `001-click-before-L42-submit-button.png`
14
- </Note>
13
+ ## Watch the replay
15
14
 
16
- ## MCP Commands
15
+ Every test run prints a link to its report when it finishes:
17
16
 
18
- ### list_local_screenshots
19
-
20
- List and filter screenshots saved in the `.testdriver/screenshots/` directory:
21
-
22
- ```
23
- list_local_screenshots()
24
- ```
25
-
26
- **Filter Parameters:**
27
-
28
- <ParamField path="directory" type="string" optional>
29
- Filter the screenshots by test file or subdirectory (for example, "login.test", "mcp-screenshots"). If you do not give this, the tool lists all screenshots.
30
- </ParamField>
31
-
32
- <ParamField path="line" type="number" optional>
33
- Filter by the exact line number from the test file (for example, 42 matches L42 in the filename).
34
- </ParamField>
35
-
36
- <ParamField path="lineRange" type="object" optional>
37
- Filter by a line number range. Example: `{ start: 10, end: 20 }` matches screenshots from lines 10-20.
38
- </ParamField>
39
-
40
- <ParamField path="action" type="string" optional>
41
- Filter by action type: `click`, `find`, `type`, `assert`, `provision`, `scroll`, `hover`, etc.
42
- </ParamField>
43
-
44
- <ParamField path="phase" type="string" optional>
45
- Filter by phase: `"before"` (state before action) or `"after"` (state after action).
46
- </ParamField>
47
-
48
- <ParamField path="pattern" type="string" optional>
49
- Regex pattern to match against filename. Example: `"login|signin"` or `"button.*click"`.
50
- </ParamField>
51
-
52
- <ParamField path="sequence" type="number" optional>
53
- Filter by exact sequence number.
54
- </ParamField>
55
-
56
- <ParamField path="sequenceRange" type="object" optional>
57
- Filter by sequence range. Example: `{ start: 1, end: 10 }` matches first 10 screenshots.
58
- </ParamField>
59
-
60
- <ParamField path="limit" type="number" optional>
61
- Maximum number of results to return (default: 50).
62
- </ParamField>
63
-
64
- <ParamField path="sortBy" type="string" optional>
65
- Sort results by: `"modified"` (newest first, default), `"sequence"` (execution order), or `"line"` (line number).
66
- </ParamField>
67
-
68
- **Returns:**
69
-
70
- Array of screenshot metadata including:
71
- - `path` - Full absolute path to the screenshot file
72
- - `relativePath` - Path relative to `.testdriver/screenshots/`
73
- - `name` - Screenshot filename
74
- - `sizeBytes` - File size in bytes
75
- - `modified` - Last modification timestamp
76
- - `sequence` - Sequential number (from auto-screenshots)
77
- - `action` - Action type (click, find, etc.)
78
- - `phase` - Before/after phase
79
- - `lineNumber` - Line number from test file
80
- - `description` - Element or action description
81
-
82
- **Example Responses:**
83
-
84
- ```json
85
- // Basic listing
86
- [
87
- {
88
- "path": "/Users/user/project/.testdriver/screenshots/login.test/001-click-before-L42-submit-button.png",
89
- "relativePath": "login.test/001-click-before-L42-submit-button.png",
90
- "name": "001-click-before-L42-submit-button.png",
91
- "sizeBytes": 145632,
92
- "modified": "2026-01-23T10:00:00.000Z",
93
- "sequence": 1,
94
- "action": "click",
95
- "phase": "before",
96
- "lineNumber": 42,
97
- "description": "submit-button"
98
- }
99
- ]
100
- ```
101
-
102
- ### view_local_screenshot
103
-
104
- View a specific screenshot from the list:
105
-
106
- ```
107
- view_local_screenshot({ path: "/full/path/to/screenshot.png" })
108
- ```
109
-
110
- **Parameters:**
111
-
112
- <ParamField path="path" type="string" required>
113
- Full absolute path to the screenshot file (as returned by `list_local_screenshots`)
114
- </ParamField>
115
-
116
- **Returns:**
117
-
118
- - Image content (displayed to both AI and user via MCP App)
119
- - Screenshot metadata
120
- - Success/error status
121
-
122
- ## Common Workflows
123
-
124
- ### Test Debugging After Failures
125
-
126
- When a test fails, you don't have to wonder what went wrong — use powerful filtering to quickly find the screenshots that show exactly what happened:
127
-
128
- **1. Find screenshots at the failing line:**
129
-
130
- ```
131
- // If test failed at line 42
132
- list_local_screenshots({ line: 42 })
133
-
134
- // View before and after states at that line
135
- view_local_screenshot({ path: ".testdriver/screenshots/login.test/005-click-before-L42-submit-button.png" })
136
- view_local_screenshot({ path: ".testdriver/screenshots/login.test/006-click-after-L42-submit-button.png" })
17
+ ```text
18
+ TESTDRIVER_RUN_URL=https://console.testdriver.ai/runs/abc123
137
19
  ```
138
20
 
139
- **2. See what happened leading up to the failure:**
21
+ The report plays a recording of the run next to a list of every command it ran, such as `find()`, `click()`, and `assert()`.
140
22
 
141
- ```
142
- // Get screenshots from lines 35-45 to see context
143
- list_local_screenshots({ directory: "login.test", lineRange: { start: 35, end: 45 } })
144
- ```
145
-
146
- **3. Find all assertion screenshots:**
147
-
148
- ```
149
- // See what the screen looked like during assertions
150
- list_local_screenshots({ action: "assert" })
151
- ```
152
-
153
- **4. View the final state before failure:**
154
-
155
- ```
156
- // Get the last 5 screenshots in execution order
157
- list_local_screenshots({ directory: "login.test", sortBy: "sequence", limit: 5 })
158
- ```
159
-
160
- ### Finding Specific Actions
23
+ Select a command to see the screen as it was when that command ran, and what the AI decided. This is the most reliable view of a failure. It shows what TestDriver saw, not what you expected on screen.
161
24
 
162
- When debugging element interactions:
25
+ Use it to answer the usual questions:
163
26
 
164
- ```
165
- // Find all click actions
166
- list_local_screenshots({ action: "click" })
27
+ - **Was the right page showing?** You see right away if a `find()` or `assert()` ran on the wrong page or before the page loaded.
28
+ - **Was the element on screen?** If `find()` couldn't locate an element, check whether it was hidden, scrolled out of view, or labelled differently.
29
+ - **Did the click land?** Compare the screen before and after a `click()` to see whether anything changed.
167
30
 
168
- // Find what the screen looked like BEFORE each click
169
- list_local_screenshots({ action: "click", phase: "before" })
31
+ ## Save a screenshot at every step
170
32
 
171
- // Find screenshots related to a specific element using regex
172
- list_local_screenshots({ pattern: "submit|button" })
33
+ To inspect a run locally, turn on automatic screenshots. TestDriver saves a screenshot before and after each `testdriver` method call and each `find()`, plus one when a call fails. Actions on an element, like `element.click()`, aren't captured:
173
34
 
174
- // Find all type actions (for form filling issues)
175
- list_local_screenshots({ action: "type" })
35
+ ```javascript
36
+ const testdriver = TestDriver(context, { autoScreenshots: true });
176
37
  ```
177
38
 
178
- ### Understanding Test Flow
179
-
180
- View screenshots in execution order to trace test behavior:
39
+ Screenshots are saved to `.testdriver/screenshots/<test file>/`. Each name records:
181
40
 
182
- ```
183
- // Get screenshots in execution order
184
- list_local_screenshots({ directory: "checkout.test", sortBy: "sequence" })
41
+ - The order.
42
+ - The command.
43
+ - The phase.
44
+ - The line of your test that ran it.
185
45
 
186
- // Get just the first 10 actions
187
- list_local_screenshots({ sequenceRange: { start: 1, end: 10 }, sortBy: "sequence" })
46
+ For example:
188
47
 
189
- // Get just the last 10 actions
190
- list_local_screenshots({ directory: "checkout.test", sortBy: "sequence", limit: 10 })
48
+ ```text
49
+ .testdriver/screenshots/login.test/
50
+ 001-find-before-L15-email-input.png
51
+ 002-find-after-L15-email-input.png
52
+ 003-type-before-L17-userexamplecom.png
53
+ 004-assert-error-L20-the-dashboard-is-visible.png
191
54
  ```
192
55
 
193
- ### Interactive Test Development
56
+ Automatic screenshots are off by default. TestDriver clears each test file's folder at the start of its next run.
194
57
 
195
- While building tests using MCP tools, view screenshots to verify your test logic:
58
+ To save a screenshot at a specific point instead, call [`screenshot()`](/screenshot). For the full naming format, see [Screenshots](/screenshots).
196
59
 
197
- 1. **After a test run**, filter screenshots to see specific actions:
60
+ ## Inspect screenshots with your AI assistant
198
61
 
199
- ```
200
- // See all assertions
201
- list_local_screenshots({ action: "assert" })
62
+ With the [local TestDriver MCP server](/mcp-setup#run-the-server-locally), your AI assistant can list and view these screenshots. Ask in plain language:
202
63
 
203
- // See what happened at a specific line you're debugging
204
- list_local_screenshots({ line: 25 })
64
+ ```text
65
+ The login test failed at line 42. Show me the screenshots from just before and after that line.
205
66
  ```
206
67
 
207
- 2. **Review key points** in the test execution:
208
-
209
- ```
210
- view_local_screenshot({ path: ".testdriver/screenshots/my-test.test/after-login.png" })
211
- ```
212
-
213
- 3. **Verify element locations and states** before adding assertions
214
-
215
- 4. **Iterate** - adjust your test code based on what you see in the screenshots
216
-
217
- ### Comparison and Analysis
218
-
219
- Compare screenshots to identify issues:
68
+ The assistant uses two MCP tools to answer:
220
69
 
221
- **Using phase filtering for before/after comparison:**
70
+ - **`list_local_screenshots`** finds screenshots by test file, line or line range, command, phase (`before`, `after`, or `error`), sequence, or a filename pattern.
71
+ - **`view_local_screenshot`** opens one of the screenshots it found, so both you and the assistant can see it.
222
72
 
223
- ```
224
- // See state before all clicks
225
- list_local_screenshots({ action: "click", phase: "before" })
73
+ These tools read the `.testdriver/` folder on the machine running the MCP server. They don't work with the hosted server at `mcp.testdriver.ai`.
226
74
 
227
- // See state after all clicks
228
- list_local_screenshots({ action: "click", phase: "after" })
229
- ```
75
+ <Accordion title="list_local_screenshots parameters">
230
76
 
231
- **Using line-based debugging:**
77
+ <ParamField path="directory" type="string">
78
+ Test file folder or subfolder to search, such as `login.test`. Searches everything when omitted.
79
+ </ParamField>
80
+ <ParamField path="line" type="number">
81
+ Exact line number in the test file. `42` matches screenshots named `L42`.
82
+ </ParamField>
83
+ <ParamField path="lineRange" type="object">
84
+ Line range to match, inclusive: `{ start: 35, end: 45 }`.
85
+ </ParamField>
86
+ <ParamField path="action" type="string">
87
+ Command name, such as `click`, `find`, `type`, or `assert`.
88
+ </ParamField>
89
+ <ParamField path="phase" type="string">
90
+ `"before"`, `"after"`, or `"error"` (taken when a command fails).
91
+ </ParamField>
92
+ <ParamField path="pattern" type="string">
93
+ Regular expression to match against filenames, such as `"login|signin"`.
94
+ </ParamField>
95
+ <ParamField path="sequence" type="number">
96
+ Exact sequence number.
97
+ </ParamField>
98
+ <ParamField path="sequenceRange" type="object">
99
+ Sequence range to match, inclusive: `{ start: 1, end: 10 }`.
100
+ </ParamField>
101
+ <ParamField path="limit" type="number" default="50">
102
+ Maximum number of results.
103
+ </ParamField>
104
+ <ParamField path="sortBy" type="string" default="modified">
105
+ `"modified"` (newest first), `"sequence"` (execution order), or `"line"`.
106
+ </ParamField>
232
107
 
233
- ```
234
- // Something went wrong around line 50
235
- list_local_screenshots({ lineRange: { start: 45, end: 55 } })
236
- ```
108
+ `view_local_screenshot` takes one parameter, `path`: the full path of a screenshot returned by `list_local_screenshots`.
237
109
 
238
- **Using regex patterns:**
110
+ </Accordion>
239
111
 
240
- ```
241
- // Find screenshots related to login functionality
242
- list_local_screenshots({ pattern: "login|signin|email|password" })
243
- ```
244
-
245
- ## Best Practices
112
+ ## Common causes
246
113
 
247
114
  <AccordionGroup>
248
- <Accordion title="Use descriptive filenames">
249
- When saving screenshots in tests, use descriptive names to make them easier to identify:
250
-
251
- ```javascript
252
- await testdriver.screenshot("initial-page-load");
253
- await testdriver.screenshot("after-login-click");
254
- await testdriver.screenshot("dashboard-loaded");
255
- ```
256
-
257
- Then when listing screenshots, you can quickly identify key moments without viewing every image.
258
- </Accordion>
259
-
260
- <Accordion title="List before viewing">
261
- Always call `list_local_screenshots` first to see what's available. The list is sorted by modification time (newest first), making it easy to find recent test runs.
262
- </Accordion>
263
-
264
- <Accordion title="Filter by test file">
265
- When debugging a specific test, use the `directory` parameter to filter screenshots:
266
-
267
- ```
268
- list_local_screenshots({ directory: "problematic-test.test" })
269
- ```
270
-
271
- This avoids clutter from other tests.
272
- </Accordion>
115
+ <Accordion title="find() acted before the page was ready">
273
116
 
274
- <Accordion title="View screenshots before and after failures">
275
- When a test fails (especially with assertions), look at screenshots immediately before the failure. They show exactly what the AI or test "saw" at that moment, helping you understand why an assertion failed or why an element wasn't found.
276
- </Accordion>
117
+ The screenshot shows a loading state or the previous page.
277
118
 
278
- <Accordion title="Combine with test reports">
279
- TestDriver test reports include screenshots in the timeline. Use MCP screenshot viewing for interactive debugging during development, and test reports for post-run analysis and team sharing.
280
- </Accordion>
119
+ Pass a `timeout` so `find()` keeps checking the screen while the page loads, for example `testdriver.find('Dashboard heading', { timeout: 30000 })`. See [Waiting for elements](/guide/best-practices-polling).
281
120
 
282
- <Accordion title="Archive important screenshots">
283
- Remember that each test run clears its screenshot folder. If you need to preserve screenshots for comparison:
284
-
285
- ```bash
286
- # Copy screenshots before next run
287
- cp -r .testdriver/screenshots/my-test.test .testdriver/screenshots-backup/
288
- ```
289
121
  </Accordion>
290
- </AccordionGroup>
291
-
292
- ## Screenshot File Organization
293
-
294
- Understanding the directory structure helps with efficient screenshot viewing:
295
-
296
- ```
297
- .testdriver/
298
- screenshots/
299
- login.test/ # Test file name (without .mjs extension)
300
- 001-find-before-L15-email-input.png # Auto: before find() at line 15
301
- 002-find-after-L15-email-input.png # Auto: after find() at line 15
302
- 003-click-before-L16-email-input.png # Auto: before click() at line 16
303
- 004-click-after-L16-email-input.png # Auto: after click() at line 16
304
- login-complete.png # Manual: screenshot("login-complete")
305
- checkout.test/
306
- 001-find-before-L12-add-to-cart.png
307
- 002-find-after-L12-add-to-cart.png
308
- ...
309
- ```
310
-
311
- ### Automatic Screenshot Naming Format
312
-
313
- `<seq>-<action>-<phase>-L<line>-<description>.png`
122
+ <Accordion title="find() picked the wrong element">
314
123
 
315
- | Component | Description | Example |
316
- |-----------|-------------|---------|
317
- | `seq` | Sequential number | `001`, `002` |
318
- | `action` | Command name | `click`, `type`, `find` |
319
- | `phase` | Before, after, or error | `before`, `after`, `error` |
320
- | `L<line>` | Line number from test file | `L42` |
321
- | `description` | Element/action description | `submit-button` |
124
+ The screenshot shows a click on a similar-looking element.
322
125
 
323
- ### Key Points
126
+ Add the element's visible label, position, or color to the description, such as "the blue Sign In button in the header". See [Locate elements](/locating-elements).
324
127
 
325
- - Each test file gets its own subdirectory
326
- - Automatic screenshots include line numbers for easy tracing
327
- - Manual `screenshot()` calls use custom names you provide
328
- - Folders are cleared at the start of each test run
329
- - All screenshots are PNG format
330
- - Disable automatic screenshots with `autoScreenshots: false` if needed
331
-
332
- ## Interaction List Sidebar (Source of Truth)
333
-
334
- When viewing a test run in the TestDriver console, the **interaction list sidebar** displays a screenshot for each interaction call (find, click, type, assert, etc.). These screenshots show exactly what was on the screen at the time each interaction was executed.
335
-
336
- <Note>
337
- **The sidebar screenshots are the source of truth.** If a test is behaving unexpectedly, check the screenshot attached to the specific interaction in the sidebar — it shows precisely what the AI saw when making its decision. This is more reliable than inferring screen state from test logs or local screenshots alone.
338
- </Note>
339
-
340
- Use the interaction list to:
341
- - **Verify what the AI saw** — confirm the correct page/state was visible when `find()` or `assert()` ran
342
- - **Debug misclicks** — see whether the target element was actually on screen
343
- - **Identify timing issues** — spot cases where the UI hadn't finished loading before an interaction fired
344
- - **Compare runs** — review interaction screenshots across multiple runs to catch flaky behavior
345
-
346
- ## Integration with Test Development
347
-
348
- ### During MCP Interactive Development
349
-
350
- When using TestDriver MCP tools (`session_start`, `find_and_click`, etc.), screenshots are automatically captured and displayed. Additionally, you can view previously saved screenshots:
351
-
352
- ```
353
- # After test development session
354
- list_local_screenshots({ directory: "my-new-test.test" })
355
- view_local_screenshot({ path: ".testdriver/screenshots/my-new-test.test/login-page.png" })
356
- ```
357
-
358
- This helps verify your test logic before running the full test file.
359
-
360
- ### After Test Runs
361
-
362
- When tests fail or behave unexpectedly, replay what happened step by step:
128
+ </Accordion>
129
+ <Accordion title="An assertion failed even though the page looks right">
363
130
 
364
- 1. **Run the test** with `vitest run tests/my-test.test.mjs`
365
- 2. **List screenshots** using `list_local_screenshots`
366
- 3. **View relevant screenshots** to diagnose the issue
367
- 4. **Update test code** based on what you see
368
- 5. **Re-run and verify** the fix
131
+ Read the AI's reasoning for the assertion in the report.
369
132
 
370
- ## Troubleshooting
133
+ Assertions that mention exact wording or several conditions at once fail more often. Check one thing at a time, in plain language. See [Make assertions](/making-assertions).
371
134
 
372
- <AccordionGroup>
373
- <Accordion title="No screenshots found">
374
- If `list_local_screenshots` returns an empty array:
375
-
376
- - Ensure your test includes `await testdriver.screenshot()` calls
377
- - Verify the test actually ran (check test output)
378
- - Check that `.testdriver/screenshots/` directory exists
379
- - Confirm you're in the correct project directory
380
135
  </Accordion>
136
+ <Accordion title="There are no screenshots in .testdriver/screenshots">
381
137
 
382
- <Accordion title="Screenshot not displaying">
383
- If `view_local_screenshot` returns an error:
384
-
385
- - Verify the path is exactly as returned by `list_local_screenshots`
386
- - Check file permissions - ensure the screenshot file is readable
387
- - Confirm the file hasn't been deleted or moved
388
- </Accordion>
138
+ Automatic screenshots are off by default. Set `autoScreenshots: true` when you create the client, or call `screenshot()` at the points you care about.
389
139
 
390
- <Accordion title="Too many screenshots">
391
- If you have hundreds of screenshots making it hard to find what you need, use filtering:
392
-
393
- - Filter by test file: `list_local_screenshots({ directory: "my-test.test" })`
394
- - Filter by line number: `list_local_screenshots({ line: 42 })` or `list_local_screenshots({ lineRange: { start: 40, end: 50 } })`
395
- - Filter by action: `list_local_screenshots({ action: "click" })`
396
- - Filter by phase: `list_local_screenshots({ phase: "before" })`
397
- - Use regex: `list_local_screenshots({ pattern: "submit|login" })`
398
- - Limit results: `list_local_screenshots({ limit: 10 })`
399
- - Sort by line: `list_local_screenshots({ sortBy: "line" })`
400
- - Clean up old folders: `rm -rf .testdriver/screenshots/*`
401
- </Accordion>
140
+ Also check that you're looking in the project folder you ran the test from.
402
141
 
403
- <Accordion title="Screenshots from old test runs">
404
- Remember that screenshot folders are cleared at the start of each test run. If you see old screenshots:
405
-
406
- - The test may not have run recently
407
- - Or the test failed before reaching the clearing logic
408
- - Manually clear: `rm -rf .testdriver/screenshots/<test-name>/`
409
142
  </Accordion>
410
143
  </AccordionGroup>
411
144
 
412
- ## Where this fits in the Guide
413
-
414
- Debugging is what you reach for when a [Run](/copilot/running-tests) goes sideways or a [Validate](/making-assertions) assertion fails — the screenshots show you precisely what the AI saw before it acted. Once you've diagnosed the failure, the next step is to stop it from recurring.
415
-
416
- ## Related
417
-
418
- - [screenshot()](/screenshot) - Capture screenshots during test execution
419
- - [Dashcam](/dashcam) - Record full test sessions with video and logs
420
- - [assert()](/assert) - Make AI-powered assertions that benefit from screenshot context
421
-
422
- ## Next
423
-
424
- <Card title="Prevent" icon="shield-check" href="/copilot/auto-healing">
425
- You've seen what went wrong — now keep it from happening again. Let auto-healing repair flaky tests automatically before they fail your suite.
426
- </Card>
145
+ ## Next steps
146
+
147
+ <CardGroup cols={2}>
148
+ <Card title="Prevent regressions" icon="shield-check" href="/copilot/auto-healing">
149
+ Catch regressions in CI and repair tests when your UI changes.
150
+ </Card>
151
+ <Card title="Errors" icon="triangle-exclamation" href="/errors">
152
+ The errors TestDriver throws and how to handle them.
153
+ </Card>
154
+ <Card title="Screenshots" icon="camera" href="/screenshots">
155
+ Naming, folders, and options for saved screenshots.
156
+ </Card>
157
+ <Card title="Dashcam" icon="video" href="/dashcam">
158
+ How runs are recorded, and how to add your own logs.
159
+ </Card>
160
+ </CardGroup>