@testdriverai/agent 7.11.240-test → 7.11.241-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 (52) hide show
  1. package/ai/skills/testdriver-agent/SKILL.md +174 -91
  2. package/ai/skills/testdriver-assert/SKILL.md +73 -269
  3. package/ai/skills/testdriver-aws-setup/SKILL.md +194 -312
  4. package/ai/skills/testdriver-bring-your-own-machine/SKILL.md +137 -204
  5. package/ai/skills/testdriver-cache/SKILL.md +142 -149
  6. package/ai/skills/testdriver-caching/SKILL.md +97 -87
  7. package/ai/skills/testdriver-captcha/SKILL.md +126 -111
  8. package/ai/skills/testdriver-ci-cd/SKILL.md +153 -542
  9. package/ai/skills/testdriver-click/SKILL.md +74 -229
  10. package/ai/skills/testdriver-client/SKILL.md +175 -229
  11. package/ai/skills/testdriver-customizing-devices/SKILL.md +72 -250
  12. package/ai/skills/testdriver-dashcam/SKILL.md +71 -404
  13. package/ai/skills/testdriver-debugging-with-screenshots/SKILL.md +103 -369
  14. package/ai/skills/testdriver-double-click/SKILL.md +46 -67
  15. package/ai/skills/testdriver-errors/SKILL.md +102 -176
  16. package/ai/skills/testdriver-events/SKILL.md +170 -327
  17. package/ai/skills/testdriver-exec/SKILL.md +92 -256
  18. package/ai/skills/testdriver-extract/SKILL.md +69 -170
  19. package/ai/skills/testdriver-find/SKILL.md +140 -736
  20. package/ai/skills/testdriver-focus-application/SKILL.md +69 -246
  21. package/ai/skills/testdriver-generating-tests/SKILL.md +102 -136
  22. package/ai/skills/testdriver-hosted/SKILL.md +79 -143
  23. package/ai/skills/testdriver-hover/SKILL.md +62 -235
  24. package/ai/skills/testdriver-locating-elements/SKILL.md +71 -366
  25. package/ai/skills/testdriver-making-assertions/SKILL.md +114 -72
  26. package/ai/skills/testdriver-mcp-setup/SKILL.md +79 -62
  27. package/ai/skills/testdriver-mouse-down/SKILL.md +46 -124
  28. package/ai/skills/testdriver-mouse-up/SKILL.md +45 -128
  29. package/ai/skills/testdriver-options/SKILL.md +73 -46
  30. package/ai/skills/testdriver-parse/SKILL.md +95 -184
  31. package/ai/skills/testdriver-performing-actions/SKILL.md +101 -91
  32. package/ai/skills/testdriver-press-keys/SKILL.md +59 -299
  33. package/ai/skills/testdriver-provision/SKILL.md +135 -179
  34. package/ai/skills/testdriver-quickstart/SKILL.md +24 -8
  35. package/ai/skills/testdriver-quickstart-claude/SKILL.md +84 -0
  36. package/ai/skills/testdriver-quickstart-github/SKILL.md +62 -32
  37. package/ai/skills/testdriver-quickstart-manual/SKILL.md +59 -32
  38. package/ai/skills/testdriver-quickstart-vscode/SKILL.md +96 -0
  39. package/ai/skills/testdriver-redraw/SKILL.md +100 -164
  40. package/ai/skills/testdriver-reusable-code/SKILL.md +95 -199
  41. package/ai/skills/testdriver-right-click/SKILL.md +45 -88
  42. package/ai/skills/testdriver-screenshot/SKILL.md +47 -201
  43. package/ai/skills/testdriver-screenshots/SKILL.md +86 -136
  44. package/ai/skills/testdriver-scroll/SKILL.md +71 -154
  45. package/ai/skills/testdriver-secrets/SKILL.md +94 -90
  46. package/ai/skills/testdriver-self-hosted/SKILL.md +82 -140
  47. package/ai/skills/testdriver-test-results-json/SKILL.md +165 -202
  48. package/ai/skills/testdriver-type/SKILL.md +56 -304
  49. package/ai/skills/testdriver-variables/SKILL.md +119 -80
  50. package/ai/skills/testdriver-wait/SKILL.md +31 -29
  51. package/ai/skills/testdriver-what-is-testdriver/SKILL.md +80 -32
  52. package/package.json +1 -1
@@ -1,248 +1,94 @@
1
1
  ---
2
2
  name: testdriver:screenshot
3
- description: Capture and save screenshots during test execution
3
+ description: Save a screenshot of the sandbox screen to a PNG file in your project.
4
4
  ---
5
5
  <!-- Generated from screenshot.mdx. DO NOT EDIT. -->
6
6
 
7
- ## Overview
7
+ Save what the sandbox screen shows right now as a PNG file. Use it to record a checkpoint you want to look at later.
8
8
 
9
- Capture a screenshot of the screen. TestDriver saves it to a local file automatically. TestDriver groups the screenshots by test file. This makes debug and review easy.
9
+ ```javascript
10
+ const screenshotPath = await testdriver.screenshot('cart-before-checkout');
11
+ ```
10
12
 
11
- <Note>
12
- **Automatic Screenshots**: TestDriver can capture screenshots automatically before and after each command (click, type, find, and more). It saves them with clear filenames such as `001-click-before-L42-submit-button.png`. The filename includes the line number from your test file. Enable this with `autoScreenshots: true` in your TestDriver options.
13
- </Note>
13
+ To capture every step without calling it yourself, turn on `autoScreenshots` instead. See [Screenshots](/screenshots).
14
14
 
15
- ## Syntax
15
+ ## Signature
16
16
 
17
- ```javascript
18
- const filePath = await testdriver.screenshot(filename)
17
+ ```typescript
18
+ testdriver.screenshot(filename?: string): Promise<string>
19
19
  ```
20
20
 
21
21
  ## Parameters
22
22
 
23
- <ParamField path="filename" type="string" optional>
24
- A custom filename for the screenshot (without the .png extension). If you do not give one, TestDriver makes a filename from the timestamp automatically.
23
+ <ParamField path="filename" type="string">
24
+ The file name. TestDriver adds `.png` if it's missing. Without it, the file is named `screenshot-<timestamp>.png`.
25
25
  </ParamField>
26
26
 
27
27
  ## Returns
28
28
 
29
- `Promise<string>` - The absolute file path where TestDriver saved the screenshot
29
+ `Promise<string>`. The absolute path of the saved file.
30
30
 
31
- ## File Organization
31
+ ## Where files are saved
32
32
 
33
- TestDriver saves screenshots automatically to `.testdriver/screenshots/<test-file-name>/` in your project root:
33
+ Screenshots go to `.testdriver/screenshots/<test file>/` in the directory you run tests from. `<test file>` is the test file's name without its last extension, so `tests/login.test.mjs` saves to `.testdriver/screenshots/login.test/`.
34
34
 
35
- ```
36
- .testdriver/
37
- screenshots/
38
- login.test/
39
- 001-find-before-L15-email-input.png # Auto: before find()
40
- 002-find-after-L15-email-input.png # Auto: after find()
41
- 003-click-before-L16-email-input.png # Auto: before click()
42
- 004-click-after-L16-email-input.png # Auto: after click()
43
- 005-type-before-L17-userexamplecom.png # Auto: before type()
44
- 006-type-after-L17-userexamplecom.png # Auto: after type()
45
- custom-screenshot.png # Manual: screenshot("custom-screenshot")
46
- checkout.test/
47
- 001-find-before-L12-checkout-button.png
48
- ...
35
+ ```text
36
+ .testdriver/screenshots/login.test/
37
+ cart-before-checkout.png
38
+ screenshot-1729512345678.png
49
39
  ```
50
40
 
51
- ### Automatic Screenshot Naming
41
+ <Warning>
42
+ TestDriver clears each test file's folder at the start of every run. Copy any screenshot you want to keep.
43
+ </Warning>
52
44
 
53
- When `autoScreenshots` is enabled, filenames follow this format:
45
+ Add the folder to `.gitignore`:
54
46
 
55
- `<seq>-<action>-<phase>-L<line>-<description>.png`
56
-
57
- | Component | Description | Example |
58
- |-----------|-------------|---------|
59
- | `seq` | Sequential number (001, 002, ...) | `001` |
60
- | `action` | Command name | `click`, `type`, `find` |
61
- | `phase` | Before, after, or error | `before`, `after` |
62
- | `L<line>` | Line number from test file | `L42` |
63
- | `description` | Element description or action target | `submit-button` |
64
-
65
- <Note>
66
- The screenshot folder for each test file is automatically cleared when the test starts. This ensures you only see screenshots from the most recent test run.
67
- </Note>
47
+ ```text .gitignore
48
+ .testdriver/screenshots/
49
+ ```
68
50
 
69
51
  ## Examples
70
52
 
71
- ### Basic Screenshot
53
+ ### Save a named checkpoint
72
54
 
73
55
  ```javascript
74
- // Capture a screenshot with auto-generated filename
75
- const screenshotPath = await testdriver.screenshot();
76
- console.log('Screenshot saved to:', screenshotPath);
56
+ await testdriver.find('Checkout button').click();
57
+ await testdriver.screenshot('checkout-page');
77
58
  ```
78
59
 
79
- ### Custom Filename
60
+ ### Log the path
80
61
 
81
62
  ```javascript
82
- // Save with a descriptive filename
83
- await testdriver.screenshot("login-page");
84
- // Saves to: .testdriver/screenshots/<test>/login-page.png
85
-
86
- await testdriver.screenshot("after-click");
87
- // Saves to: .testdriver/screenshots/<test>/after-click.png
63
+ const screenshotPath = await testdriver.screenshot();
64
+ console.log(screenshotPath);
65
+ // /Users/you/my-app/.testdriver/screenshots/login.test/screenshot-1729512345678.png
88
66
  ```
89
67
 
90
- ### Debugging with Screenshots
68
+ ## Complete example
91
69
 
92
- ```javascript
93
- import { describe, expect, it } from "vitest";
94
- import { TestDriver } from "testdriverai/vitest/hooks";
70
+ ```javascript tests/login.test.mjs
71
+ import { describe, expect, it } from 'vitest';
72
+ import { TestDriver } from 'testdriverai/vitest/hooks';
95
73
 
96
- describe("Login Flow", () => {
97
- it("should log in successfully", async (context) => {
74
+ describe('Login', () => {
75
+ it('shows an error for an empty form', async (context) => {
98
76
  const testdriver = TestDriver(context);
99
-
100
- await testdriver.provision.chrome({
101
- url: 'https://myapp.com/login',
102
- });
103
-
104
- // Capture initial state
105
- await testdriver.screenshot();
106
-
107
- // Fill in login form
108
- const emailInput = await testdriver.find("email input");
109
- await emailInput.click();
110
- await testdriver.type("user@example.com");
111
-
112
- // Capture state after typing
113
- await testdriver.screenshot();
77
+ await testdriver.provision.chrome({ url: 'https://testdriver-sandbox.vercel.app/login' });
114
78
 
115
- const passwordInput = await testdriver.find("password input");
116
- await passwordInput.click();
117
- await testdriver.type("password123");
79
+ await testdriver.screenshot('login-empty');
118
80
 
119
- // Capture before clicking login
120
- await testdriver.screenshot();
81
+ await testdriver.find('Sign in button below the password field').click();
82
+ await testdriver.screenshot('login-error');
121
83
 
122
- const loginButton = await testdriver.find("Login button");
123
- await loginButton.click();
124
-
125
- // Capture after login attempt
126
- await testdriver.screenshot();
127
-
128
- const result = await testdriver.assert("dashboard is visible");
129
- expect(result).toBeTruthy();
84
+ const result = await testdriver.assert('an error says the fields are required');
85
+ expect(result).toBe(true);
130
86
  });
131
87
  });
132
88
  ```
133
89
 
134
- ## Automatic Screenshots
135
-
136
- By default, TestDriver captures screenshots **automatically** before and after every command. This creates a complete visual timeline of your test execution without any additional code.
137
-
138
- ### Enabling/Disabling
139
-
140
- ```javascript
141
- // Auto-screenshots enabled by default
142
- const testdriver = TestDriver(context);
143
-
144
- // Explicitly disable if needed (not recommended)
145
- const testdriver = TestDriver(context, {
146
- autoScreenshots: false
147
- });
148
- ```
149
-
150
- ### What Gets Captured
151
-
152
- Automatic screenshots are taken around these commands:
153
- - `find()` / `findAll()`
154
- - `click()` / `hover()` / `doubleClick()` / `rightClick()`
155
- - `type()` / `pressKeys()`
156
- - `scroll()`
157
- - `waitForText()` / `waitForImage()`
158
- - `focusApplication()`
159
- - `assert()` / `extract()` / `exec()`
160
-
161
- ### Example Output
162
-
163
- For this test code:
164
-
165
- ```javascript
166
- // Line 15: Find email input
167
- const emailInput = await testdriver.find("email input");
168
- // Line 16: Click it
169
- await emailInput.click();
170
- // Line 17: Type email
171
- await testdriver.type("user@example.com");
172
- ```
173
-
174
- TestDriver automatically saves:
175
-
176
- ```
177
- 001-find-before-L15-email-input.png
178
- 002-find-after-L15-email-input.png
179
- 003-click-before-L16-email-input.png
180
- 004-click-after-L16-email-input.png
181
- 005-type-before-L17-userexamplecom.png
182
- 006-type-after-L17-userexamplecom.png
183
- ```
184
-
185
- If an error occurs, the phase will be `error` instead of `after`.
186
-
187
- ## Best Practices
188
-
189
- <AccordionGroup>
190
- <Accordion title="Let automatic screenshots do the work">
191
- With `autoScreenshots: true`, you get comprehensive coverage without adding manual `screenshot()` calls. Only add manual screenshots for specific named checkpoints.
192
- </Accordion>
193
-
194
- <Accordion title="Use screenshots for debugging flaky tests">
195
- When a test fails intermittently, add screenshots at key steps to capture the actual screen state. This helps identify timing issues or unexpected UI states.
196
- </Accordion>
197
-
198
- <Accordion title="Capture before assertions">
199
- Take a screenshot before making assertions. If the assertion fails, you'll have a visual record of what the screen looked like.
200
-
201
- ```javascript
202
- await testdriver.screenshot();
203
- const result = await testdriver.assert("checkout button is visible");
204
- ```
205
- </Accordion>
206
-
207
- <Accordion title="Add to .gitignore">
208
- Add `.testdriver/screenshots/` to your `.gitignore` to avoid committing screenshots to version control:
209
-
210
- ```
211
- # .gitignore
212
- .testdriver/screenshots/
213
- ```
214
- </Accordion>
215
- </AccordionGroup>
216
-
217
- ## Viewing Saved Screenshots
218
-
219
- After saving screenshots during test execution, you can view them using TestDriver MCP commands. This is especially useful for debugging failed tests or verifying test behavior.
220
-
221
- ### MCP Commands for Screenshot Viewing
222
-
223
- **List all saved screenshots:**
224
-
225
- ```
226
- list_local_screenshots()
227
- ```
228
-
229
- **View a specific screenshot:**
230
-
231
- ```
232
- view_local_screenshot({ path: "/full/path/to/screenshot.png" })
233
- ```
234
-
235
- These commands allow you to:
236
- - View screenshots from failed tests to understand what went wrong
237
- - Review test execution flow by examining screenshots in chronological order
238
- - Compare screenshots across test runs to identify flaky behavior
239
-
240
- <Note>
241
- For detailed workflows and examples of using these MCP commands for debugging, see the [Debugging with Screenshots](/debugging-with-screenshots) guide.
242
- </Note>
243
-
244
90
  ## Related
245
91
 
246
- - [Debugging with Screenshots](/debugging-with-screenshots) - View and analyze saved screenshots using MCP
247
- - [assert()](/assert) - Make AI-powered assertions
248
- - [find()](/find) - Locate elements on screen
92
+ - [Screenshots](/screenshots): capture every step automatically with `autoScreenshots`
93
+ - [Debug a failing test](/debugging-with-screenshots): view saved screenshots from your AI client
94
+ - [Dashcam](/dashcam): watch a video replay of the whole test
@@ -1,184 +1,134 @@
1
1
  ---
2
2
  name: testdriver:screenshots
3
- description: Capture and manage screenshots during test execution
3
+ description: Save screenshots of the sandbox by hand or automatically around each command.
4
4
  ---
5
5
  <!-- Generated from screenshots.mdx. DO NOT EDIT. -->
6
6
 
7
- ## Overview
7
+ TestDriver can save screenshots of the sandbox to your machine while a test runs.
8
8
 
9
- TestDriver can capture screenshots by hand at any point during a test. It can also capture them automatically before and after each command. TestDriver saves the screenshots to a structured directory. This makes debug easy.
9
+ - Call [`screenshot()`](/screenshot) to save one at a specific point.
10
+ - Turn on `autoScreenshots` to save one before and after each command, named after the line that ran it.
10
11
 
11
- ## Manual Screenshots
12
+ Both kinds are saved as PNG files in `.testdriver/screenshots/<test file>/`.
12
13
 
13
- Use `testdriver.screenshot()` to capture the present screen:
14
+ ## Save a screenshot by hand
14
15
 
15
- ```javascript
16
- const path = await testdriver.screenshot();
17
- console.log('Saved to:', path);
18
- // .testdriver/screenshots/my-test/screenshot-1719849312345.png
19
- ```
20
-
21
- ### Options
16
+ Call `screenshot()` with an optional file name. It resolves to the absolute path of the saved file:
22
17
 
23
- ```javascript
24
- await testdriver.screenshot(filename?)
25
- ```
18
+ ```javascript tests/login.test.mjs
19
+ import { describe, it } from 'vitest';
20
+ import { TestDriver } from 'testdriverai/vitest/hooks';
26
21
 
27
- <ParamField path="filename" type="string">
28
- A custom filename for the screenshot. TestDriver adds `.png` automatically if it is not there. If you do not give this, the default is `screenshot-<timestamp>.png`.
29
- </ParamField>
22
+ describe('Login', () => {
23
+ it('loads the login page', async (context) => {
24
+ const testdriver = TestDriver(context);
25
+ await testdriver.provision.chrome({ url: 'https://testdriver-sandbox.vercel.app/login' });
30
26
 
31
- **Returns:** `Promise<string>` — the absolute file path of the saved screenshot.
32
-
33
- ```javascript
34
- // Default filename
35
- await testdriver.screenshot();
36
- // → .testdriver/screenshots/my-test/screenshot-1719849312345.png
27
+ const filePath = await testdriver.screenshot('login-page');
28
+ console.log(filePath);
29
+ // /path/to/project/.testdriver/screenshots/login.test/login-page.png
30
+ });
31
+ });
32
+ ```
37
33
 
38
- // Custom filename
39
- await testdriver.screenshot('login-page');
40
- // → .testdriver/screenshots/my-test/login-page.png
34
+ - TestDriver adds `.png` if the name doesn't end with it.
35
+ - Without a name, the file is called `screenshot-<timestamp>.png`.
41
36
 
42
- // With .png extension
43
- await testdriver.screenshot('dashboard-loaded.png');
44
- // → .testdriver/screenshots/my-test/dashboard-loaded.png
45
- ```
37
+ See [screenshot()](/screenshot) for the full reference.
46
38
 
47
- ## Auto Screenshots
39
+ ## Save screenshots automatically
48
40
 
49
- Enable automatic screenshots before and after every command:
41
+ Set `autoScreenshots: true` when you create the client:
50
42
 
51
43
  ```javascript
52
- const testdriver = new TestDriver({
53
- autoScreenshots: true,
54
- });
44
+ const testdriver = TestDriver(context, { autoScreenshots: true });
55
45
  ```
56
46
 
57
- <ParamField path="autoScreenshots" type="boolean" default={false}>
58
- When `true`, captures a screenshot before and after every SDK command (`click`, `type`, `find`, `scroll`, `hover`, `pressKeys`, `assert`, `exec`, etc.). On error, an error-phase screenshot replaces the after-phase screenshot.
59
- </ParamField>
60
-
61
- ### Filename Format
62
-
63
- Auto-screenshots follow this naming convention:
64
-
65
- ```
66
- <seq>-<action>-<phase>-L<line>-<description>.png
67
- ```
47
+ TestDriver then saves a screenshot before each command and another after it. When a command fails, it saves an `error` screenshot instead of the `after` one. A failed screenshot never fails the command.
68
48
 
69
- | Part | Description | Example |
70
- |---|---|---|
71
- | `seq` | 3-digit zero-padded sequence number | `001` |
72
- | `action` | Command name | `click`, `type`, `find` |
73
- | `phase` | `before`, `after`, or `error` | `before` |
74
- | `L<line>` | Source line number from your test file | `L42` |
75
- | `description` | Sanitized from command arguments (max 30 chars) | `submit-button` |
49
+ Automatic screenshots are off by default because each one is an extra capture from the sandbox.
76
50
 
77
- **Examples:**
78
- ```
79
- 001-find-before-L15-login-button.png
80
- 002-find-after-L15-login-button.png
81
- 003-click-before-L16-login-button.png
82
- 004-click-after-L16-login-button.png
83
- 005-type-before-L18-username-field.png
84
- 006-type-error-L18-username-field.png
85
- ```
51
+ ### Which commands are captured
86
52
 
87
- ### Phases
53
+ - `find()` and `findAll()`.
54
+ - Methods you call on the client, such as `testdriver.click()`, `type()`, `pressKeys()`, `scroll()`, `hover()`, `wait()`, `assert()`, `extract()`, `exec()`, and `focusApplication()`.
88
55
 
89
- | Phase | When | Description |
90
- |---|---|---|
91
- | `before` | Before command executes | Captures the screen state before the action |
92
- | `after` | After successful command | Captures the result of the action |
93
- | `error` | After failed command | Captures the screen at the point of failure (replaces `after`) |
56
+ <Note>
57
+ Methods you call on an element, such as `element.click()` or `element.hover()`, aren't captured. The `find()` that returned the element is.
58
+ </Note>
94
59
 
95
- ## Screenshot Directory
60
+ ### File names
96
61
 
97
- Screenshots are saved to:
62
+ Each automatic screenshot is named:
98
63
 
99
- ```
100
- <cwd>/.testdriver/screenshots/<testFileName>/
64
+ ```text
65
+ <sequence>-<command>-<phase>-L<line>-<description>.png
101
66
  ```
102
67
 
103
- Where `<testFileName>` is the test file name without its extension. For example, a test at `tests/login.test.mjs` saves screenshots to `.testdriver/screenshots/login.test/`.
68
+ | Part | Meaning | Example |
69
+ | --- | --- | --- |
70
+ | `sequence` | Three-digit counter, in the order screenshots were taken | `001` |
71
+ | `command` | The method that ran | `find`, `type`, `assert` |
72
+ | `phase` | `before`, `after`, or `error` | `before` |
73
+ | `L<line>` | The line in your test file that called the command | `L15` |
74
+ | `description` | Taken from the command's arguments, as below | `email-input` |
104
75
 
105
- ### Directory Cleanup
76
+ The description comes from:
106
77
 
107
- The screenshot directory for each test file is **automatically cleaned** at the start of a test run. This happens once per process per test file to prevent concurrent tests from the same file from interfering with each other.
78
+ - The description passed to `find()` or `findAll()`.
79
+ - The first 20 characters typed by `type()`.
80
+ - The keys passed to `pressKeys()`, joined with `+`.
81
+ - The direction passed to `scroll()`.
82
+ - The first 30 characters of the text passed to `assert()` or `extract()`.
108
83
 
109
- ## Debug Screenshots
84
+ TestDriver lowercases it, drops anything other than letters, digits, spaces, and hyphens, turns spaces into hyphens, and keeps the first 30 characters.
110
85
 
111
- Elements have a `saveDebugScreenshot()` method for debugging element detection:
86
+ <Warning>
87
+ The description for `type()` uses the typed text even when you pass `secret: true`. Don't turn on `autoScreenshots` for tests that type passwords, or the start of the password ends up in a file name.
88
+ </Warning>
112
89
 
113
- ```javascript
114
- const el = await testdriver.find('submit button');
90
+ ### Example
115
91
 
116
- // Save the screenshot that was used to detect this element
117
- const debugPath = await el.saveDebugScreenshot();
118
- console.log('Debug screenshot:', debugPath);
119
- // → ./debug-screenshot-1719849312345.png
92
+ This test:
120
93
 
121
- // Custom path
122
- await el.saveDebugScreenshot('./my-debug.png');
94
+ ```javascript
95
+ await testdriver.find('Email input field').click(); // line 15
96
+ await testdriver.type('user@example.com'); // line 16
97
+ await testdriver.assert('the email is filled in'); // line 17
123
98
  ```
124
99
 
125
- This saves the screenshot that was captured during the `find()` call, which can be useful for understanding what the AI "saw" when locating the element.
100
+ saves:
126
101
 
127
- ## Complete Example
128
-
129
- ```javascript
130
- import { describe, it, beforeAll, afterAll } from 'vitest';
131
- import TestDriver from 'testdriverai';
132
-
133
- describe('Screenshot Example', () => {
134
- let testdriver;
135
-
136
- beforeAll(async () => {
137
- testdriver = new TestDriver({
138
- autoScreenshots: true, // capture every step
139
- });
140
- await testdriver.ready();
141
- await testdriver.provision.chrome({ url: 'https://example.com' });
142
- });
102
+ ```text
103
+ .testdriver/screenshots/login.test/
104
+ 001-find-before-L15-email-input-field.png
105
+ 002-find-after-L15-email-input-field.png
106
+ 003-type-before-L16-userexamplecom.png
107
+ 004-type-after-L16-userexamplecom.png
108
+ 005-assert-before-L17-the-email-is-filled-in.png
109
+ 006-assert-after-L17-the-email-is-filled-in.png
110
+ ```
143
111
 
144
- afterAll(async () => {
145
- await testdriver.disconnect();
146
- });
112
+ ## Where screenshots are saved
147
113
 
148
- it('captures the login flow', async () => {
149
- // Auto-screenshots capture before/after each command
114
+ Screenshots go in a folder named after the test file, without its last extension:
150
115
 
151
- // Manual screenshot for a specific moment
152
- await testdriver.screenshot('initial-page-load');
116
+ | Test file | Folder |
117
+ | --- | --- |
118
+ | `tests/login.test.mjs` | `.testdriver/screenshots/login.test/` |
119
+ | `tests/checkout.spec.js` | `.testdriver/screenshots/checkout.spec/` |
153
120
 
154
- const username = await testdriver.find('username input');
155
- await username.click();
156
- await testdriver.type('testuser@example.com');
121
+ The `.testdriver` folder is created in the directory you run the tests from.
157
122
 
158
- await testdriver.screenshot('after-username-entry');
123
+ TestDriver deletes a test file's screenshot folder when that file's first test connects to a sandbox. Each folder only holds screenshots from the latest run. Tests in the same file running at the same time don't delete each other's screenshots.
159
124
 
160
- const password = await testdriver.find('password input');
161
- await password.click();
162
- await testdriver.type('password123');
125
+ ## Review the screenshots
163
126
 
164
- await testdriver.find('login button').click();
127
+ Open the folder after a run, or ask your AI assistant to find and show screenshots by line number. [Debug a failing test](/debugging-with-screenshots#inspect-screenshots-with-your-ai-assistant) explains how to do that with the TestDriver MCP server.
165
128
 
166
- await testdriver.screenshot('after-login-click');
167
- });
168
- });
169
- ```
129
+ ## Related
170
130
 
171
- After running, your screenshot directory will contain:
172
- ```
173
- .testdriver/screenshots/login-flow.test/
174
- ├── initial-page-load.png
175
- ├── 001-find-before-L18-username-input.png
176
- ├── 002-find-after-L18-username-input.png
177
- ├── 003-click-before-L19-username-input.png
178
- ├── 004-click-after-L19-username-input.png
179
- ├── 005-type-before-L20-testuser-example-com.png
180
- ├── 006-type-after-L20-testuser-example-com.png
181
- ├── after-username-entry.png
182
- ├── 007-find-before-L24-password-input.png
183
- ├── ...
184
- ```
131
+ - [screenshot()](/screenshot): the reference for manual screenshots
132
+ - [Debug a failing test](/debugging-with-screenshots): use replays and screenshots to find out why a test failed
133
+ - [Dashcam](/dashcam): the video recording of each run
134
+ - [Options](/options#preview-and-recording): every client option