testdriverai 7.3.12 → 7.3.13
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.
- package/.github/skills/testdriver:ai/SKILL.md +204 -0
- package/.github/skills/testdriver:assert/SKILL.md +284 -0
- package/.github/skills/testdriver:aws-setup/SKILL.md +515 -0
- package/.github/skills/testdriver:caching/SKILL.md +124 -0
- package/.github/skills/testdriver:captcha/SKILL.md +159 -0
- package/.github/skills/testdriver:ci-cd/SKILL.md +602 -0
- package/.github/skills/testdriver:click/SKILL.md +286 -0
- package/.github/skills/testdriver:client/SKILL.md +339 -0
- package/.github/skills/testdriver:cloud/SKILL.md +119 -0
- package/.github/skills/testdriver:customizing-devices/SKILL.md +153 -0
- package/.github/skills/testdriver:dashcam/SKILL.md +418 -0
- package/.github/skills/testdriver:debugging-with-screenshots/SKILL.md +271 -0
- package/.github/skills/testdriver:device-config/SKILL.md +317 -0
- package/.github/skills/testdriver:double-click/SKILL.md +102 -0
- package/.github/skills/testdriver:elements/SKILL.md +605 -0
- package/.github/skills/testdriver:enterprise/SKILL.md +114 -0
- package/.github/skills/testdriver:examples/SKILL.md +7 -0
- package/.github/skills/testdriver:exec/SKILL.md +345 -0
- package/.github/skills/testdriver:find/SKILL.md +721 -0
- package/.github/skills/testdriver:focus-application/SKILL.md +293 -0
- package/.github/skills/testdriver:generating-tests/SKILL.md +36 -0
- package/.github/skills/testdriver:hover/SKILL.md +278 -0
- package/.github/skills/testdriver:locating-elements/SKILL.md +71 -0
- package/.github/skills/testdriver:making-assertions/SKILL.md +32 -0
- package/.github/skills/testdriver:mcp-workflow/SKILL.md +410 -0
- package/.github/skills/testdriver:mouse-down/SKILL.md +161 -0
- package/.github/skills/testdriver:mouse-up/SKILL.md +164 -0
- package/.github/skills/testdriver:performing-actions/SKILL.md +51 -0
- package/.github/skills/testdriver:press-keys/SKILL.md +348 -0
- package/.github/skills/testdriver:quickstart/SKILL.md +161 -0
- package/.github/skills/testdriver:reusable-code/SKILL.md +240 -0
- package/.github/skills/testdriver:right-click/SKILL.md +123 -0
- package/.github/skills/testdriver:running-tests/SKILL.md +181 -0
- package/.github/skills/testdriver:screenshot/SKILL.md +167 -0
- package/.github/skills/testdriver:scroll/SKILL.md +299 -0
- package/.github/skills/testdriver:secrets/SKILL.md +115 -0
- package/.github/skills/testdriver:self-hosted/SKILL.md +65 -0
- package/.github/skills/testdriver:test-writer/SKILL.md +451 -0
- package/.github/skills/testdriver:testdriver/SKILL.md +523 -0
- package/.github/skills/testdriver:testdriver-mechanic/SKILL.md +165 -0
- package/.github/skills/testdriver:type/SKILL.md +357 -0
- package/.github/skills/testdriver:variables/SKILL.md +111 -0
- package/.github/skills/testdriver:waiting-for-elements/SKILL.md +66 -0
- package/.github/skills/testdriver:what-is-testdriver/SKILL.md +54 -0
- package/.github/workflows/acceptance-windows-scheduled.yaml +6 -1
- package/.github/workflows/acceptance.yaml +0 -36
- package/.github/workflows/update-examples.yaml +53 -0
- package/CHANGELOG.md +4 -0
- package/agent/events.js +1 -0
- package/agent/index.js +8 -0
- package/agent/lib/commands.js +48 -29
- package/agent/lib/redraw.js +3 -1
- package/agent/lib/sandbox.js +166 -14
- package/agent/lib/sdk.js +142 -3
- package/agent/lib/system.js +4 -6
- package/ai/skills/testdriver:ai/SKILL.md +204 -0
- package/ai/skills/testdriver:assert/SKILL.md +315 -0
- package/ai/skills/testdriver:aws-setup/SKILL.md +448 -0
- package/ai/skills/testdriver:caching/SKILL.md +124 -0
- package/ai/skills/testdriver:captcha/SKILL.md +159 -0
- package/ai/skills/testdriver:ci-cd/SKILL.md +602 -0
- package/ai/skills/testdriver:click/SKILL.md +286 -0
- package/ai/skills/testdriver:client/SKILL.md +372 -0
- package/ai/skills/testdriver:cloud/SKILL.md +119 -0
- package/ai/skills/testdriver:customizing-devices/SKILL.md +153 -0
- package/ai/skills/testdriver:dashcam/SKILL.md +418 -0
- package/ai/skills/testdriver:debugging-with-screenshots/SKILL.md +401 -0
- package/ai/skills/testdriver:device-config/SKILL.md +317 -0
- package/ai/skills/testdriver:double-click/SKILL.md +102 -0
- package/ai/skills/testdriver:elements/SKILL.md +605 -0
- package/ai/skills/testdriver:enterprise/SKILL.md +114 -0
- package/ai/skills/testdriver:examples/SKILL.md +7 -0
- package/ai/skills/testdriver:exec/SKILL.md +345 -0
- package/ai/skills/testdriver:find/SKILL.md +745 -0
- package/ai/skills/testdriver:focus-application/SKILL.md +293 -0
- package/ai/skills/testdriver:generating-tests/SKILL.md +36 -0
- package/ai/skills/testdriver:hover/SKILL.md +278 -0
- package/ai/skills/testdriver:locating-elements/SKILL.md +71 -0
- package/ai/skills/testdriver:making-assertions/SKILL.md +32 -0
- package/ai/skills/testdriver:mcp-workflow/SKILL.md +410 -0
- package/ai/skills/testdriver:mouse-down/SKILL.md +161 -0
- package/ai/skills/testdriver:mouse-up/SKILL.md +164 -0
- package/ai/skills/testdriver:ocr/SKILL.md +235 -0
- package/ai/skills/testdriver:performing-actions/SKILL.md +51 -0
- package/ai/skills/testdriver:press-keys/SKILL.md +348 -0
- package/ai/skills/testdriver:quickstart/SKILL.md +146 -0
- package/ai/skills/testdriver:reusable-code/SKILL.md +240 -0
- package/ai/skills/testdriver:right-click/SKILL.md +123 -0
- package/ai/skills/testdriver:running-tests/SKILL.md +185 -0
- package/ai/skills/testdriver:screenshot/SKILL.md +248 -0
- package/ai/skills/testdriver:scroll/SKILL.md +335 -0
- package/ai/skills/testdriver:secrets/SKILL.md +115 -0
- package/ai/skills/testdriver:self-hosted/SKILL.md +65 -0
- package/ai/skills/testdriver:test-writer/SKILL.md +451 -0
- package/ai/skills/testdriver:testdriver/SKILL.md +631 -0
- package/ai/skills/testdriver:testdriver-mechanic/SKILL.md +165 -0
- package/ai/skills/testdriver:type/SKILL.md +357 -0
- package/ai/skills/testdriver:variables/SKILL.md +111 -0
- package/ai/skills/testdriver:waiting-for-elements/SKILL.md +66 -0
- package/ai/skills/testdriver:what-is-testdriver/SKILL.md +54 -0
- package/debugger/index.html +12 -2
- package/docs/v7/examples/scroll-keyboard.mdx +1 -1
- package/docs/v7/find.mdx +1 -0
- package/examples/config.mjs +1 -1
- package/examples/findall-coffee-icons.test.mjs +42 -0
- package/examples/flake-diffthreshold-001.test.mjs +9 -0
- package/examples/flake-diffthreshold-01.test.mjs +9 -0
- package/examples/flake-diffthreshold-05.test.mjs +9 -0
- package/examples/{z_flake-noredraw-cache.test.mjs → flake-noredraw-cache.test.mjs} +2 -2
- package/examples/{z_flake-noredraw-nocache.test.mjs → flake-noredraw-nocache.test.mjs} +2 -2
- package/examples/{z_flake-redraw-cache.test.mjs → flake-redraw-cache.test.mjs} +2 -2
- package/examples/{z_flake-redraw-nocache.test.mjs → flake-redraw-nocache.test.mjs} +2 -2
- package/examples/flake-rocket-match.test.mjs +30 -0
- package/examples/{z_flake-shared.mjs → flake-shared.mjs} +2 -2
- package/examples/parse.test.mjs +19 -0
- package/examples/scroll-keyboard.test.mjs +1 -1
- package/interfaces/cli/lib/base.js +6 -0
- package/interfaces/logger.js +51 -13
- package/interfaces/vitest-plugin.mjs +137 -0
- package/lib/core/index.d.ts +22 -0
- package/lib/init-project.js +105 -6
- package/lib/vitest/hooks.mjs +2 -5
- package/lib/vitest/setup-disable-defender.mjs +52 -0
- package/package.json +2 -1
- package/sdk-log-formatter.js +90 -0
- package/sdk.d.ts +88 -51
- package/sdk.js +126 -18
- package/setup/aws/disable-defender.sh +42 -0
- package/vitest.config.mjs +1 -3
- package/examples/z_flake-diffthreshold-001.test.mjs +0 -9
- package/examples/z_flake-diffthreshold-01.test.mjs +0 -9
- package/examples/z_flake-diffthreshold-05.test.mjs +0 -9
- /package/{examples → manual}/captcha-api.test.mjs +0 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testdriver:debugging-with-screenshots
|
|
3
|
+
description: View and analyze saved screenshots using MCP commands for test debugging and development
|
|
4
|
+
---
|
|
5
|
+
<!-- Generated from debugging-with-screenshots.mdx. DO NOT EDIT. -->
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
TestDriver MCP provides powerful commands to view and analyze screenshots saved during test execution. This enables rapid debugging, test development, and comparison workflows without manually opening image files.
|
|
10
|
+
|
|
11
|
+
## MCP Commands
|
|
12
|
+
|
|
13
|
+
### list_local_screenshots
|
|
14
|
+
|
|
15
|
+
List all screenshots saved in the `.testdriver/screenshots/` directory:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
list_local_screenshots()
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Optional Parameters:**
|
|
22
|
+
|
|
23
|
+
<ParamField path="directory" type="string" optional>
|
|
24
|
+
Filter screenshots by subdirectory (e.g., specific test file). If omitted, lists all screenshots.
|
|
25
|
+
</ParamField>
|
|
26
|
+
|
|
27
|
+
**Returns:**
|
|
28
|
+
|
|
29
|
+
Array of screenshot metadata including:
|
|
30
|
+
- `path` - Full absolute path to the screenshot file
|
|
31
|
+
- `relativePath` - Path relative to `.testdriver/screenshots/`
|
|
32
|
+
- `testFile` - The test file that created this screenshot
|
|
33
|
+
- `filename` - Screenshot filename
|
|
34
|
+
- `size` - File size in bytes
|
|
35
|
+
- `modified` - Last modification timestamp
|
|
36
|
+
- `created` - Creation timestamp
|
|
37
|
+
|
|
38
|
+
**Example Response:**
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
[
|
|
42
|
+
{
|
|
43
|
+
"path": "/Users/user/project/.testdriver/screenshots/login.test/screenshot-1737633600000.png",
|
|
44
|
+
"relativePath": "login.test/screenshot-1737633600000.png",
|
|
45
|
+
"testFile": "login.test",
|
|
46
|
+
"filename": "screenshot-1737633600000.png",
|
|
47
|
+
"size": 145632,
|
|
48
|
+
"modified": "2026-01-23T10:00:00.000Z",
|
|
49
|
+
"created": "2026-01-23T10:00:00.000Z"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### view_local_screenshot
|
|
55
|
+
|
|
56
|
+
View a specific screenshot from the list:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
view_local_screenshot({ path: "/full/path/to/screenshot.png" })
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Parameters:**
|
|
63
|
+
|
|
64
|
+
<ParamField path="path" type="string" required>
|
|
65
|
+
Full absolute path to the screenshot file (as returned by `list_local_screenshots`)
|
|
66
|
+
</ParamField>
|
|
67
|
+
|
|
68
|
+
**Returns:**
|
|
69
|
+
|
|
70
|
+
- Image content (displayed to both AI and user via MCP App)
|
|
71
|
+
- Screenshot metadata
|
|
72
|
+
- Success/error status
|
|
73
|
+
|
|
74
|
+
## Common Workflows
|
|
75
|
+
|
|
76
|
+
### Test Debugging After Failures
|
|
77
|
+
|
|
78
|
+
When a test fails, view the saved screenshots to understand what went wrong:
|
|
79
|
+
|
|
80
|
+
1. **List screenshots from the failed test:**
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
list_local_screenshots({ directory: "login.test" })
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
2. **View screenshots in chronological order** (sorted by creation time) to trace the test execution:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
view_local_screenshot({ path: ".testdriver/screenshots/login.test/screenshot-1737633600000.png" })
|
|
90
|
+
view_local_screenshot({ path: ".testdriver/screenshots/login.test/screenshot-1737633610000.png" })
|
|
91
|
+
view_local_screenshot({ path: ".testdriver/screenshots/login.test/screenshot-1737633620000.png" })
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
3. **Analyze the UI state** at each step to identify where things went wrong
|
|
95
|
+
|
|
96
|
+
4. **Compare expected vs actual** - if you added descriptive filenames with `screenshot("step-name")`, you can easily identify key moments
|
|
97
|
+
|
|
98
|
+
### Interactive Test Development
|
|
99
|
+
|
|
100
|
+
While building tests using MCP tools, view screenshots to verify your test logic:
|
|
101
|
+
|
|
102
|
+
1. **After a test run**, list screenshots to see what was captured:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
list_local_screenshots()
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
2. **Review key points** in the test execution:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
view_local_screenshot({ path: ".testdriver/screenshots/my-test.test/after-login.png" })
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
3. **Verify element locations and states** before adding assertions
|
|
115
|
+
|
|
116
|
+
4. **Iterate** - adjust your test code based on what you see in the screenshots
|
|
117
|
+
|
|
118
|
+
### Comparison and Analysis
|
|
119
|
+
|
|
120
|
+
Compare screenshots across multiple test runs to identify flaky behavior or UI changes:
|
|
121
|
+
|
|
122
|
+
1. **List screenshots from multiple test runs** (note: each test run clears the folder, so copy screenshots elsewhere for comparison if needed)
|
|
123
|
+
|
|
124
|
+
2. **View screenshots side-by-side** to spot differences:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
view_local_screenshot({ path: ".testdriver/screenshots/test.test/before-click.png" })
|
|
128
|
+
// Analyze first run
|
|
129
|
+
|
|
130
|
+
view_local_screenshot({ path: ".testdriver/screenshots-backup/test.test/before-click.png" })
|
|
131
|
+
// Compare with previous run
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
3. **Identify timing issues** - if element positions or states vary between runs, you may have timing/race condition issues
|
|
135
|
+
|
|
136
|
+
## Best Practices
|
|
137
|
+
|
|
138
|
+
<AccordionGroup>
|
|
139
|
+
<Accordion title="Use descriptive filenames">
|
|
140
|
+
When saving screenshots in tests, use descriptive names to make them easier to identify:
|
|
141
|
+
|
|
142
|
+
```javascript
|
|
143
|
+
await testdriver.screenshot("initial-page-load");
|
|
144
|
+
await testdriver.screenshot("after-login-click");
|
|
145
|
+
await testdriver.screenshot("dashboard-loaded");
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Then when listing screenshots, you can quickly identify key moments without viewing every image.
|
|
149
|
+
</Accordion>
|
|
150
|
+
|
|
151
|
+
<Accordion title="List before viewing">
|
|
152
|
+
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.
|
|
153
|
+
</Accordion>
|
|
154
|
+
|
|
155
|
+
<Accordion title="Filter by test file">
|
|
156
|
+
When debugging a specific test, use the `directory` parameter to filter screenshots:
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
list_local_screenshots({ directory: "problematic-test.test" })
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
This avoids clutter from other tests.
|
|
163
|
+
</Accordion>
|
|
164
|
+
|
|
165
|
+
<Accordion title="View screenshots before and after failures">
|
|
166
|
+
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.
|
|
167
|
+
</Accordion>
|
|
168
|
+
|
|
169
|
+
<Accordion title="Combine with test reports">
|
|
170
|
+
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.
|
|
171
|
+
</Accordion>
|
|
172
|
+
|
|
173
|
+
<Accordion title="Archive important screenshots">
|
|
174
|
+
Remember that each test run clears its screenshot folder. If you need to preserve screenshots for comparison:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Copy screenshots before next run
|
|
178
|
+
cp -r .testdriver/screenshots/my-test.test .testdriver/screenshots-backup/
|
|
179
|
+
```
|
|
180
|
+
</Accordion>
|
|
181
|
+
</AccordionGroup>
|
|
182
|
+
|
|
183
|
+
## Screenshot File Organization
|
|
184
|
+
|
|
185
|
+
Understanding the directory structure helps with efficient screenshot viewing:
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
.testdriver/
|
|
189
|
+
screenshots/
|
|
190
|
+
login.test/ # Test file name (without .mjs extension)
|
|
191
|
+
screenshot-1737633600000.png # Auto-generated timestamp filename
|
|
192
|
+
initial-state.png # Custom descriptive filename
|
|
193
|
+
after-click.png
|
|
194
|
+
checkout.test/
|
|
195
|
+
screenshot-1737633700000.png
|
|
196
|
+
product-page.png
|
|
197
|
+
profile.test/
|
|
198
|
+
screenshot-1737633800000.png
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
- Each test file gets its own subdirectory
|
|
202
|
+
- Filenames are either timestamps (default) or custom names you provide
|
|
203
|
+
- Folders are cleared at the start of each test run
|
|
204
|
+
- All screenshots are PNG format
|
|
205
|
+
|
|
206
|
+
## Integration with Test Development
|
|
207
|
+
|
|
208
|
+
### During MCP Interactive Development
|
|
209
|
+
|
|
210
|
+
When using TestDriver MCP tools (`session_start`, `find_and_click`, etc.), screenshots are automatically captured and displayed. Additionally, you can view previously saved screenshots:
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
# After test development session
|
|
214
|
+
list_local_screenshots({ directory: "my-new-test.test" })
|
|
215
|
+
view_local_screenshot({ path: ".testdriver/screenshots/my-new-test.test/login-page.png" })
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
This helps verify your test logic before running the full test file.
|
|
219
|
+
|
|
220
|
+
### After Test Runs
|
|
221
|
+
|
|
222
|
+
When tests fail or behave unexpectedly:
|
|
223
|
+
|
|
224
|
+
1. **Run the test** with `vitest run tests/my-test.test.mjs`
|
|
225
|
+
2. **List screenshots** using `list_local_screenshots`
|
|
226
|
+
3. **View relevant screenshots** to diagnose the issue
|
|
227
|
+
4. **Update test code** based on what you see
|
|
228
|
+
5. **Re-run and verify** the fix
|
|
229
|
+
|
|
230
|
+
## Troubleshooting
|
|
231
|
+
|
|
232
|
+
<AccordionGroup>
|
|
233
|
+
<Accordion title="No screenshots found">
|
|
234
|
+
If `list_local_screenshots` returns an empty array:
|
|
235
|
+
|
|
236
|
+
- Ensure your test includes `await testdriver.screenshot()` calls
|
|
237
|
+
- Verify the test actually ran (check test output)
|
|
238
|
+
- Check that `.testdriver/screenshots/` directory exists
|
|
239
|
+
- Confirm you're in the correct project directory
|
|
240
|
+
</Accordion>
|
|
241
|
+
|
|
242
|
+
<Accordion title="Screenshot not displaying">
|
|
243
|
+
If `view_local_screenshot` returns an error:
|
|
244
|
+
|
|
245
|
+
- Verify the path is exactly as returned by `list_local_screenshots`
|
|
246
|
+
- Check file permissions - ensure the screenshot file is readable
|
|
247
|
+
- Confirm the file hasn't been deleted or moved
|
|
248
|
+
</Accordion>
|
|
249
|
+
|
|
250
|
+
<Accordion title="Too many screenshots">
|
|
251
|
+
If you have hundreds of screenshots making it hard to find what you need:
|
|
252
|
+
|
|
253
|
+
- Use the `directory` parameter to filter by test file
|
|
254
|
+
- Consider adding more descriptive filenames in your tests
|
|
255
|
+
- Clean up old screenshot folders: `rm -rf .testdriver/screenshots/*`
|
|
256
|
+
</Accordion>
|
|
257
|
+
|
|
258
|
+
<Accordion title="Screenshots from old test runs">
|
|
259
|
+
Remember that screenshot folders are cleared at the start of each test run. If you see old screenshots:
|
|
260
|
+
|
|
261
|
+
- The test may not have run recently
|
|
262
|
+
- Or the test failed before reaching the clearing logic
|
|
263
|
+
- Manually clear: `rm -rf .testdriver/screenshots/<test-name>/`
|
|
264
|
+
</Accordion>
|
|
265
|
+
</AccordionGroup>
|
|
266
|
+
|
|
267
|
+
## Related
|
|
268
|
+
|
|
269
|
+
- [screenshot()](/v7/screenshot) - Capture screenshots during test execution
|
|
270
|
+
- [Dashcam](/v7/dashcam) - Record full test sessions with video and logs
|
|
271
|
+
- [assert()](/v7/assert) - Make AI-powered assertions that benefit from screenshot context
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testdriver:device-config
|
|
3
|
+
description: Launch browsers, desktop apps, and extensions in your TestDriver sandbox
|
|
4
|
+
---
|
|
5
|
+
<!-- Generated from device-config.mdx. DO NOT EDIT. -->
|
|
6
|
+
|
|
7
|
+
Provision methods are the starting point for most tests. They launch applications in your sandbox and prepare the environment for testing.
|
|
8
|
+
|
|
9
|
+
## Chrome Browser
|
|
10
|
+
|
|
11
|
+
The most common starting point for web testing. Launches Chrome browser and navigates to a URL.
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
await testdriver.provision.chrome({
|
|
15
|
+
url: 'https://example.com',
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Options
|
|
20
|
+
|
|
21
|
+
| Option | Type | Default | Description |
|
|
22
|
+
|--------|------|---------|-------------|
|
|
23
|
+
| `url` | string | `'http://testdriver-sandbox.vercel.app/'` | URL to navigate to |
|
|
24
|
+
| `maximized` | boolean | `true` | Start browser maximized |
|
|
25
|
+
| `guest` | boolean | `false` | Use guest mode (no profile) |
|
|
26
|
+
|
|
27
|
+
### Example: Basic Web Test
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
import { describe, expect, it } from "vitest";
|
|
31
|
+
import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
|
|
32
|
+
|
|
33
|
+
describe("Login Flow", () => {
|
|
34
|
+
it("should log in successfully", async (context) => {
|
|
35
|
+
const testdriver = TestDriver(context);
|
|
36
|
+
|
|
37
|
+
await testdriver.provision.chrome({
|
|
38
|
+
url: 'https://myapp.com/login',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
await testdriver.find("Email input").click();
|
|
42
|
+
await testdriver.type("user@example.com");
|
|
43
|
+
|
|
44
|
+
await testdriver.find("Password input").click();
|
|
45
|
+
await testdriver.type("password123");
|
|
46
|
+
|
|
47
|
+
await testdriver.find("Sign In button").click();
|
|
48
|
+
|
|
49
|
+
const result = await testdriver.assert("the dashboard is visible");
|
|
50
|
+
expect(result).toBeTruthy();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
<Info>
|
|
56
|
+
`provision.chrome()` automatically starts Dashcam recording and waits for Chrome to be ready before returning.
|
|
57
|
+
</Info>
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Chrome Extensions
|
|
62
|
+
|
|
63
|
+
Launch Chrome with a custom extension loaded. Supports both local extensions and Chrome Web Store extensions.
|
|
64
|
+
|
|
65
|
+
### Load from Local Path
|
|
66
|
+
|
|
67
|
+
Clone or create an extension locally, then load it:
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
// First, get the extension onto the sandbox
|
|
71
|
+
await testdriver.exec(
|
|
72
|
+
'sh',
|
|
73
|
+
'git clone https://github.com/user/my-extension.git /tmp/my-extension',
|
|
74
|
+
60000
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// Launch Chrome with the extension
|
|
78
|
+
await testdriver.provision.chromeExtension({
|
|
79
|
+
extensionPath: '/tmp/my-extension',
|
|
80
|
+
url: 'https://example.com'
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Load from Chrome Web Store
|
|
85
|
+
|
|
86
|
+
Load any published extension by its Chrome Web Store ID:
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
await testdriver.provision.chromeExtension({
|
|
90
|
+
extensionId: 'cjpalhdlnbpafiamejdnhcphjbkeiagm', // uBlock Origin
|
|
91
|
+
url: 'https://example.com'
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
<Tip>
|
|
96
|
+
Find the extension ID in the Chrome Web Store URL. For example, `https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm` → ID is `cjpalhdlnbpafiamejdnhcphjbkeiagm`
|
|
97
|
+
</Tip>
|
|
98
|
+
|
|
99
|
+
### Options
|
|
100
|
+
|
|
101
|
+
| Option | Type | Default | Description |
|
|
102
|
+
|--------|------|---------|-------------|
|
|
103
|
+
| `extensionPath` | string | - | Local path to unpacked extension directory |
|
|
104
|
+
| `extensionId` | string | - | Chrome Web Store extension ID |
|
|
105
|
+
| `url` | string | - | URL to navigate to after launch |
|
|
106
|
+
| `maximized` | boolean | `true` | Start browser maximized |
|
|
107
|
+
|
|
108
|
+
<Warning>
|
|
109
|
+
You must provide either `extensionPath` or `extensionId`, but not both.
|
|
110
|
+
</Warning>
|
|
111
|
+
|
|
112
|
+
### Example: Testing a Chrome Extension
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
import { describe, expect, it } from "vitest";
|
|
116
|
+
import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
|
|
117
|
+
|
|
118
|
+
describe("Chrome Extension Test", () => {
|
|
119
|
+
it("should load and interact with extension", async (context) => {
|
|
120
|
+
const testdriver = TestDriver(context);
|
|
121
|
+
|
|
122
|
+
// Clone extension from GitHub
|
|
123
|
+
await testdriver.exec(
|
|
124
|
+
'sh',
|
|
125
|
+
'git clone https://github.com/user/my-extension.git /tmp/my-extension',
|
|
126
|
+
60000,
|
|
127
|
+
true
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
// Launch Chrome with extension loaded
|
|
131
|
+
await testdriver.provision.chromeExtension({
|
|
132
|
+
extensionPath: '/tmp/my-extension',
|
|
133
|
+
url: 'https://testdriver.ai'
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// Click extensions puzzle icon
|
|
137
|
+
const extensionsButton = await testdriver.find("puzzle-shaped icon in Chrome toolbar");
|
|
138
|
+
await extensionsButton.click();
|
|
139
|
+
|
|
140
|
+
// Interact with your extension
|
|
141
|
+
const myExtension = await testdriver.find("My Extension in the dropdown");
|
|
142
|
+
await myExtension.click();
|
|
143
|
+
|
|
144
|
+
const result = await testdriver.assert("extension popup is visible");
|
|
145
|
+
expect(result).toBeTruthy();
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Desktop Apps
|
|
153
|
+
|
|
154
|
+
Download and install desktop applications. Supports `.deb`, `.rpm`, `.msi`, `.exe`, `.AppImage`, `.dmg`, `.pkg`, and shell scripts.
|
|
155
|
+
|
|
156
|
+
```javascript
|
|
157
|
+
const filePath = await testdriver.provision.installer({
|
|
158
|
+
url: 'https://example.com/app.deb',
|
|
159
|
+
appName: 'MyApp', // Focus this app after install
|
|
160
|
+
launch: true, // Auto-launch after install
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Options
|
|
165
|
+
|
|
166
|
+
| Option | Type | Default | Description |
|
|
167
|
+
|--------|------|---------|-------------|
|
|
168
|
+
| `url` | string | **required** | URL to download the installer from |
|
|
169
|
+
| `filename` | string | auto-detected | Filename to save as |
|
|
170
|
+
| `appName` | string | - | Application name to focus after install |
|
|
171
|
+
| `launch` | boolean | `true` | Launch the app after installation |
|
|
172
|
+
|
|
173
|
+
### Supported File Types
|
|
174
|
+
|
|
175
|
+
| Extension | OS | Install Method |
|
|
176
|
+
|-----------|-----|----------------|
|
|
177
|
+
| `.deb` | Linux | `dpkg -i` + `apt-get install -f` |
|
|
178
|
+
| `.rpm` | Linux | `rpm -i` |
|
|
179
|
+
| `.AppImage` | Linux | `chmod +x` |
|
|
180
|
+
| `.sh` | Linux | `chmod +x` + execute |
|
|
181
|
+
| `.msi` | Windows | `msiexec /i /quiet` |
|
|
182
|
+
| `.exe` | Windows | Silent install (`/S`) |
|
|
183
|
+
| `.dmg` | macOS | Mount + copy to Applications |
|
|
184
|
+
| `.pkg` | macOS | `installer -pkg` |
|
|
185
|
+
|
|
186
|
+
### Example: Install and Test a Desktop App
|
|
187
|
+
|
|
188
|
+
```javascript
|
|
189
|
+
import { describe, expect, it } from "vitest";
|
|
190
|
+
import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
|
|
191
|
+
|
|
192
|
+
describe("Desktop App Test", () => {
|
|
193
|
+
it("should install and launch app", async (context) => {
|
|
194
|
+
const testdriver = TestDriver(context);
|
|
195
|
+
|
|
196
|
+
// Download and install
|
|
197
|
+
const installerPath = await testdriver.provision.installer({
|
|
198
|
+
url: 'https://github.com/sharkdp/bat/releases/download/v0.24.0/bat_0.24.0_amd64.deb',
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// Verify installation
|
|
202
|
+
const output = await testdriver.exec('sh', 'bat --version', 5000);
|
|
203
|
+
expect(output).toContain('bat');
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Example: Windows Installer
|
|
209
|
+
|
|
210
|
+
```javascript
|
|
211
|
+
import { describe, expect, it } from "vitest";
|
|
212
|
+
import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
|
|
213
|
+
|
|
214
|
+
describe("Windows App Test", () => {
|
|
215
|
+
it("should install on Windows", async (context) => {
|
|
216
|
+
const testdriver = TestDriver(context, {
|
|
217
|
+
os: 'windows'
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// Download MSI installer
|
|
221
|
+
const installerPath = await testdriver.provision.installer({
|
|
222
|
+
url: 'https://example.com/app.msi',
|
|
223
|
+
launch: false, // Don't auto-launch
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// Custom installation if needed
|
|
227
|
+
await testdriver.exec(
|
|
228
|
+
'pwsh',
|
|
229
|
+
`Start-Process msiexec.exe -ArgumentList "/i", "${installerPath}", "/qn" -Wait`,
|
|
230
|
+
120000
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
// Verify installation
|
|
234
|
+
const result = await testdriver.assert("application is installed");
|
|
235
|
+
expect(result).toBeTruthy();
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Manual Installation
|
|
241
|
+
|
|
242
|
+
Set `launch: false` to download without auto-installing:
|
|
243
|
+
|
|
244
|
+
```javascript
|
|
245
|
+
const filePath = await testdriver.provision.installer({
|
|
246
|
+
url: 'https://example.com/custom-script.sh',
|
|
247
|
+
launch: false,
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// Run custom install commands
|
|
251
|
+
await testdriver.exec('sh', `chmod +x "${filePath}"`, 5000);
|
|
252
|
+
await testdriver.exec('sh', `"${filePath}" --custom-flag`, 60000);
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## VS Code
|
|
258
|
+
|
|
259
|
+
Launch Visual Studio Code with optional workspace and extensions.
|
|
260
|
+
|
|
261
|
+
```javascript
|
|
262
|
+
await testdriver.provision.vscode({
|
|
263
|
+
workspace: '/home/testdriver/my-project',
|
|
264
|
+
extensions: ['ms-python.python', 'esbenp.prettier-vscode'],
|
|
265
|
+
});
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Options
|
|
269
|
+
|
|
270
|
+
| Option | Type | Default | Description |
|
|
271
|
+
|--------|------|---------|-------------|
|
|
272
|
+
| `workspace` | string | - | Workspace folder to open |
|
|
273
|
+
| `extensions` | string[] | `[]` | Extensions to install (by ID) |
|
|
274
|
+
|
|
275
|
+
### Example: VS Code Extension Test
|
|
276
|
+
|
|
277
|
+
```javascript
|
|
278
|
+
import { describe, expect, it } from "vitest";
|
|
279
|
+
import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
|
|
280
|
+
|
|
281
|
+
describe("VS Code Test", () => {
|
|
282
|
+
it("should open workspace with extensions", async (context) => {
|
|
283
|
+
const testdriver = TestDriver(context);
|
|
284
|
+
|
|
285
|
+
// Create a test project
|
|
286
|
+
await testdriver.exec('sh', 'mkdir -p /tmp/test-project && echo "print(1)" > /tmp/test-project/test.py', 10000);
|
|
287
|
+
|
|
288
|
+
// Launch VS Code
|
|
289
|
+
await testdriver.provision.vscode({
|
|
290
|
+
workspace: '/tmp/test-project',
|
|
291
|
+
extensions: ['ms-python.python'],
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// Verify VS Code is ready
|
|
295
|
+
const result = await testdriver.assert("VS Code is open with the project");
|
|
296
|
+
expect(result).toBeTruthy();
|
|
297
|
+
|
|
298
|
+
// Open the Python file
|
|
299
|
+
await testdriver.find("test.py in the explorer").click();
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## Choosing the Right Provision Method
|
|
307
|
+
|
|
308
|
+
| Use Case | Method |
|
|
309
|
+
|----------|--------|
|
|
310
|
+
| Testing a website | `provision.chrome` |
|
|
311
|
+
| Testing a Chrome extension | `provision.chromeExtension` |
|
|
312
|
+
| Testing a desktop app (needs installation) | `provision.installer` |
|
|
313
|
+
| Testing VS Code or VS Code extensions | `provision.vscode` |
|
|
314
|
+
|
|
315
|
+
<Tip>
|
|
316
|
+
All provision methods automatically start Dashcam recording and wait for the application to be ready before returning. You don't need to call `dashcam.start()` manually.
|
|
317
|
+
</Tip>
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testdriver:double-click
|
|
3
|
+
description: Perform a double-click action on an element or at specific coordinates
|
|
4
|
+
---
|
|
5
|
+
<!-- Generated from double-click.mdx. DO NOT EDIT. -->
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
The `doubleClick()` method performs a double-click action on an element. You can either call it on an [`Element`](/v7/core-concepts/elements) instance or use it directly with a selector.
|
|
10
|
+
|
|
11
|
+
## Syntax
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
// Double-click on an element
|
|
15
|
+
await element.doubleClick();
|
|
16
|
+
|
|
17
|
+
// Double-click using a selector
|
|
18
|
+
await ai.doubleClick('selector');
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Parameters
|
|
22
|
+
|
|
23
|
+
When called on an `Element`, no parameters are required.
|
|
24
|
+
|
|
25
|
+
When called directly on the AI client:
|
|
26
|
+
|
|
27
|
+
| Parameter | Type | Description |
|
|
28
|
+
|-----------|------|-------------|
|
|
29
|
+
| `selector` | `string` | The selector describing the element to double-click |
|
|
30
|
+
|
|
31
|
+
## Returns
|
|
32
|
+
|
|
33
|
+
Returns a `Promise<void>` that resolves when the double-click action completes.
|
|
34
|
+
|
|
35
|
+
## Examples
|
|
36
|
+
|
|
37
|
+
### Double-Click on Found Element
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
const fileItem = await ai.find('README.md file');
|
|
41
|
+
await fileItem.doubleClick();
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Direct Double-Click with Selector
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
await ai.doubleClick('README.md in the file list');
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Opening Files in VS Code
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
import { test } from 'vitest';
|
|
54
|
+
import { vscode } from '@testdriver/sdk';
|
|
55
|
+
|
|
56
|
+
test('opens a file by double-clicking', async () => {
|
|
57
|
+
const { ai } = await vscode();
|
|
58
|
+
|
|
59
|
+
// Double-click to open a file in the explorer
|
|
60
|
+
await ai.doubleClick('package.json in the file explorer');
|
|
61
|
+
|
|
62
|
+
// Verify the file opened
|
|
63
|
+
const editor = await ai.find('text editor showing package.json');
|
|
64
|
+
expect(editor).toBeTruthy();
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Opening Folders in File Manager
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
import { test } from 'vitest';
|
|
72
|
+
import { chrome } from '@testdriver/sdk';
|
|
73
|
+
|
|
74
|
+
test('navigates folders in Google Drive', async () => {
|
|
75
|
+
const { ai } = await chrome('https://drive.google.com');
|
|
76
|
+
|
|
77
|
+
// Double-click to open a folder
|
|
78
|
+
await ai.doubleClick('Documents folder');
|
|
79
|
+
|
|
80
|
+
// Wait for folder to open
|
|
81
|
+
await ai.find('breadcrumb showing Documents');
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Selecting Text with Double-Click
|
|
86
|
+
|
|
87
|
+
```javascript
|
|
88
|
+
// Double-click to select a word
|
|
89
|
+
await ai.doubleClick('word "TestDriver" in the paragraph');
|
|
90
|
+
|
|
91
|
+
// Verify selection
|
|
92
|
+
const selectedText = await ai.exec('window.getSelection().toString()');
|
|
93
|
+
expect(selectedText).toBe('TestDriver');
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Related Methods
|
|
97
|
+
|
|
98
|
+
- [`click()`](/v7/click) - Single click on an element
|
|
99
|
+
- [`rightClick()`](/v7/right-click) - Right-click to open context menu
|
|
100
|
+
- [`mouseDown()`](/v7/mouse-down) - Press mouse button without releasing
|
|
101
|
+
- [`mouseUp()`](/v7/mouse-up) - Release mouse button
|
|
102
|
+
- [`hover()`](/v7/hover) - Move mouse over element without clicking
|