testdriverai 7.3.11 → 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 +8 -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 +128 -21
- 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,348 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testdriver:press-keys
|
|
3
|
+
description: Press keyboard keys and shortcuts
|
|
4
|
+
---
|
|
5
|
+
<!-- Generated from press-keys.mdx. DO NOT EDIT. -->
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Press one or more keyboard keys simultaneously, useful for keyboard shortcuts, navigation, and special keys.
|
|
10
|
+
|
|
11
|
+
## Syntax
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
await testdriver.pressKeys(keys)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
<ParamField path="keys" type="Array<string>" required>
|
|
20
|
+
Array of keys to press simultaneously
|
|
21
|
+
</ParamField>
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`Promise<void>`
|
|
26
|
+
|
|
27
|
+
## Common Keys
|
|
28
|
+
|
|
29
|
+
### Special Keys
|
|
30
|
+
- `'enter'`, `'tab'`, `'escape'`, `'backspace'`, `'delete'`
|
|
31
|
+
- `'space'`, `'up'`, `'down'`, `'left'`, `'right'`
|
|
32
|
+
- `'home'`, `'end'`, `'pageup'`, `'pagedown'`
|
|
33
|
+
|
|
34
|
+
### Modifier Keys
|
|
35
|
+
- `'ctrl'`, `'alt'`, `'shift'`
|
|
36
|
+
- `'command'` (macOS), `'win'` (Windows)
|
|
37
|
+
- `'ctrlleft'`, `'ctrlright'`, `'shiftleft'`, `'shiftright'`
|
|
38
|
+
|
|
39
|
+
### Function Keys
|
|
40
|
+
- `'f1'` through `'f24'`
|
|
41
|
+
|
|
42
|
+
## Examples
|
|
43
|
+
|
|
44
|
+
### Navigation
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
// Tab to next field
|
|
48
|
+
await testdriver.pressKeys(['tab']);
|
|
49
|
+
|
|
50
|
+
// Shift+Tab to previous field
|
|
51
|
+
await testdriver.pressKeys(['shift', 'tab']);
|
|
52
|
+
|
|
53
|
+
// Arrow keys
|
|
54
|
+
await testdriver.pressKeys(['down']);
|
|
55
|
+
await testdriver.pressKeys(['up']);
|
|
56
|
+
await testdriver.pressKeys(['left']);
|
|
57
|
+
await testdriver.pressKeys(['right']);
|
|
58
|
+
|
|
59
|
+
// Home/End
|
|
60
|
+
await testdriver.pressKeys(['home']); // Start of line
|
|
61
|
+
await testdriver.pressKeys(['end']); // End of line
|
|
62
|
+
|
|
63
|
+
// Page navigation
|
|
64
|
+
await testdriver.pressKeys(['pagedown']);
|
|
65
|
+
await testdriver.pressKeys(['pageup']);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Keyboard Shortcuts
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
// Copy (Ctrl+C / Cmd+C)
|
|
72
|
+
await testdriver.pressKeys(['ctrl', 'c']);
|
|
73
|
+
|
|
74
|
+
// Paste (Ctrl+V / Cmd+V)
|
|
75
|
+
await testdriver.pressKeys(['ctrl', 'v']);
|
|
76
|
+
|
|
77
|
+
// Save (Ctrl+S)
|
|
78
|
+
await testdriver.pressKeys(['ctrl', 's']);
|
|
79
|
+
|
|
80
|
+
// Select All (Ctrl+A)
|
|
81
|
+
await testdriver.pressKeys(['ctrl', 'a']);
|
|
82
|
+
|
|
83
|
+
// Undo (Ctrl+Z)
|
|
84
|
+
await testdriver.pressKeys(['ctrl', 'z']);
|
|
85
|
+
|
|
86
|
+
// Redo (Ctrl+Y)
|
|
87
|
+
await testdriver.pressKeys(['ctrl', 'y']);
|
|
88
|
+
|
|
89
|
+
// Find (Ctrl+F)
|
|
90
|
+
await testdriver.pressKeys(['ctrl', 'f']);
|
|
91
|
+
|
|
92
|
+
// New tab (Ctrl+T)
|
|
93
|
+
await testdriver.pressKeys(['ctrl', 't']);
|
|
94
|
+
|
|
95
|
+
// Close tab (Ctrl+W)
|
|
96
|
+
await testdriver.pressKeys(['ctrl', 'w']);
|
|
97
|
+
|
|
98
|
+
// Refresh (F5 or Ctrl+R)
|
|
99
|
+
await testdriver.pressKeys(['f5']);
|
|
100
|
+
await testdriver.pressKeys(['ctrl', 'r']);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### System Shortcuts
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
// Alt+Tab (Windows - switch apps)
|
|
107
|
+
await testdriver.pressKeys(['alt', 'tab']);
|
|
108
|
+
|
|
109
|
+
// Alt+F4 (Windows - close window)
|
|
110
|
+
await testdriver.pressKeys(['alt', 'f4']);
|
|
111
|
+
|
|
112
|
+
// Win+D (Windows - show desktop)
|
|
113
|
+
await testdriver.pressKeys(['winleft', 'd']);
|
|
114
|
+
|
|
115
|
+
// Win+L (Windows - lock screen)
|
|
116
|
+
await testdriver.pressKeys(['winleft', 'l']);
|
|
117
|
+
|
|
118
|
+
// Cmd+Tab (macOS - switch apps)
|
|
119
|
+
await testdriver.pressKeys(['command', 'tab']);
|
|
120
|
+
|
|
121
|
+
// Cmd+Q (macOS - quit app)
|
|
122
|
+
await testdriver.pressKeys(['command', 'q']);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Form Submission
|
|
126
|
+
|
|
127
|
+
```javascript
|
|
128
|
+
// Submit form
|
|
129
|
+
await testdriver.pressKeys(['enter']);
|
|
130
|
+
|
|
131
|
+
// Cancel/Close
|
|
132
|
+
await testdriver.pressKeys(['escape']);
|
|
133
|
+
|
|
134
|
+
// Check checkbox
|
|
135
|
+
await testdriver.pressKeys(['space']);
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Text Editing
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
// Delete selected text
|
|
142
|
+
await testdriver.pressKeys(['delete']);
|
|
143
|
+
|
|
144
|
+
// Backspace
|
|
145
|
+
await testdriver.pressKeys(['backspace']);
|
|
146
|
+
|
|
147
|
+
// Select all and delete
|
|
148
|
+
await testdriver.pressKeys(['ctrl', 'a']);
|
|
149
|
+
await testdriver.pressKeys(['delete']);
|
|
150
|
+
|
|
151
|
+
// Cut text
|
|
152
|
+
await testdriver.pressKeys(['ctrl', 'x']);
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Best Practices
|
|
156
|
+
|
|
157
|
+
<Check>
|
|
158
|
+
**Wait after shortcuts**
|
|
159
|
+
|
|
160
|
+
Some keyboard shortcuts trigger animations or navigation:
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
await testdriver.pressKeys(['ctrl', 't']); // New tab
|
|
164
|
+
await new Promise(r => setTimeout(r, 500)); // Wait for tab
|
|
165
|
+
await testdriver.pressKeys(['ctrl', 'l']); // Focus URL bar
|
|
166
|
+
```
|
|
167
|
+
</Check>
|
|
168
|
+
|
|
169
|
+
<Check>
|
|
170
|
+
**Use Tab for form navigation**
|
|
171
|
+
|
|
172
|
+
Tab is more reliable than clicking multiple fields:
|
|
173
|
+
|
|
174
|
+
```javascript
|
|
175
|
+
const firstField = await testdriver.find('email input');
|
|
176
|
+
await firstField.click();
|
|
177
|
+
await testdriver.type('user@example.com');
|
|
178
|
+
|
|
179
|
+
await testdriver.pressKeys(['tab']);
|
|
180
|
+
await testdriver.type('password123');
|
|
181
|
+
|
|
182
|
+
await testdriver.pressKeys(['tab']);
|
|
183
|
+
await testdriver.pressKeys(['enter']); // Submit
|
|
184
|
+
```
|
|
185
|
+
</Check>
|
|
186
|
+
|
|
187
|
+
<Warning>
|
|
188
|
+
**Platform-specific keys**
|
|
189
|
+
|
|
190
|
+
Use the appropriate modifier key for the platform:
|
|
191
|
+
- Windows/Linux: `'ctrl'`
|
|
192
|
+
- macOS: `'command'`
|
|
193
|
+
|
|
194
|
+
```javascript
|
|
195
|
+
// For cross-platform, you might need to detect OS
|
|
196
|
+
const modKey = process.platform === 'darwin' ? 'command' : 'ctrl';
|
|
197
|
+
await testdriver.pressKeys([modKey, 'c']); // Copy
|
|
198
|
+
```
|
|
199
|
+
</Warning>
|
|
200
|
+
|
|
201
|
+
## Use Cases
|
|
202
|
+
|
|
203
|
+
<AccordionGroup>
|
|
204
|
+
<Accordion title="Form Navigation">
|
|
205
|
+
```javascript
|
|
206
|
+
// Fill form using Tab
|
|
207
|
+
const firstField = await testdriver.find('name field');
|
|
208
|
+
await firstField.click();
|
|
209
|
+
await testdriver.type('John Doe');
|
|
210
|
+
|
|
211
|
+
await testdriver.pressKeys(['tab']);
|
|
212
|
+
await testdriver.type('john@example.com');
|
|
213
|
+
|
|
214
|
+
await testdriver.pressKeys(['tab']);
|
|
215
|
+
await testdriver.type('555-0123');
|
|
216
|
+
|
|
217
|
+
await testdriver.pressKeys(['tab']);
|
|
218
|
+
await testdriver.pressKeys(['enter']); // Submit
|
|
219
|
+
```
|
|
220
|
+
</Accordion>
|
|
221
|
+
|
|
222
|
+
<Accordion title="Text Manipulation">
|
|
223
|
+
```javascript
|
|
224
|
+
const textArea = await testdriver.find('comment textarea');
|
|
225
|
+
await textArea.click();
|
|
226
|
+
|
|
227
|
+
// Select all existing text
|
|
228
|
+
await testdriver.pressKeys(['ctrl', 'a']);
|
|
229
|
+
|
|
230
|
+
// Copy it
|
|
231
|
+
await testdriver.pressKeys(['ctrl', 'c']);
|
|
232
|
+
|
|
233
|
+
// Type new text
|
|
234
|
+
await testdriver.type('New comment');
|
|
235
|
+
|
|
236
|
+
// Undo if needed
|
|
237
|
+
await testdriver.pressKeys(['ctrl', 'z']);
|
|
238
|
+
```
|
|
239
|
+
</Accordion>
|
|
240
|
+
|
|
241
|
+
<Accordion title="Browser Navigation">
|
|
242
|
+
```javascript
|
|
243
|
+
// Open new tab
|
|
244
|
+
await testdriver.pressKeys(['ctrl', 't']);
|
|
245
|
+
await new Promise(r => setTimeout(r, 500));
|
|
246
|
+
|
|
247
|
+
// Focus address bar
|
|
248
|
+
await testdriver.pressKeys(['ctrl', 'l']);
|
|
249
|
+
await testdriver.type('https://example.com');
|
|
250
|
+
await testdriver.pressKeys(['enter']);
|
|
251
|
+
|
|
252
|
+
// Refresh page
|
|
253
|
+
await testdriver.pressKeys(['f5']);
|
|
254
|
+
|
|
255
|
+
// Close tab
|
|
256
|
+
await testdriver.pressKeys(['ctrl', 'w']);
|
|
257
|
+
```
|
|
258
|
+
</Accordion>
|
|
259
|
+
|
|
260
|
+
<Accordion title="Application Shortcuts">
|
|
261
|
+
```javascript
|
|
262
|
+
// Save document
|
|
263
|
+
await testdriver.pressKeys(['ctrl', 's']);
|
|
264
|
+
|
|
265
|
+
// Print
|
|
266
|
+
await testdriver.pressKeys(['ctrl', 'p']);
|
|
267
|
+
|
|
268
|
+
// Find in page
|
|
269
|
+
await testdriver.pressKeys(['ctrl', 'f']);
|
|
270
|
+
await testdriver.type('search term');
|
|
271
|
+
await testdriver.pressKeys(['escape']); // Close find
|
|
272
|
+
```
|
|
273
|
+
</Accordion>
|
|
274
|
+
</AccordionGroup>
|
|
275
|
+
|
|
276
|
+
## Complete Example
|
|
277
|
+
|
|
278
|
+
```javascript
|
|
279
|
+
import { beforeAll, afterAll, describe, it } from 'vitest';
|
|
280
|
+
import TestDriver from 'testdriverai';
|
|
281
|
+
|
|
282
|
+
describe('Keyboard Navigation', () => {
|
|
283
|
+
let testdriver;
|
|
284
|
+
|
|
285
|
+
beforeAll(async () => {
|
|
286
|
+
client = new TestDriver(process.env.TD_API_KEY);
|
|
287
|
+
await testdriver.auth();
|
|
288
|
+
await testdriver.connect();
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
afterAll(async () => {
|
|
292
|
+
await testdriver.disconnect();
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it('should navigate form with keyboard', async () => {
|
|
296
|
+
await testdriver.focusApplication('Google Chrome');
|
|
297
|
+
|
|
298
|
+
// Find first field
|
|
299
|
+
const emailField = await testdriver.find('email input');
|
|
300
|
+
await emailField.click();
|
|
301
|
+
await testdriver.type('user@example.com');
|
|
302
|
+
|
|
303
|
+
// Tab through fields
|
|
304
|
+
await testdriver.pressKeys(['tab']);
|
|
305
|
+
await testdriver.type('John');
|
|
306
|
+
|
|
307
|
+
await testdriver.pressKeys(['tab']);
|
|
308
|
+
await testdriver.type('Doe');
|
|
309
|
+
|
|
310
|
+
await testdriver.pressKeys(['tab']);
|
|
311
|
+
await testdriver.type('password123');
|
|
312
|
+
|
|
313
|
+
// Submit with Enter
|
|
314
|
+
await testdriver.pressKeys(['tab']);
|
|
315
|
+
await testdriver.pressKeys(['enter']);
|
|
316
|
+
|
|
317
|
+
await testdriver.assert('form submitted successfully');
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
it('should use keyboard shortcuts', async () => {
|
|
321
|
+
// Open new browser tab
|
|
322
|
+
await testdriver.pressKeys(['ctrl', 't']);
|
|
323
|
+
await new Promise(r => setTimeout(r, 500));
|
|
324
|
+
|
|
325
|
+
// Focus address bar
|
|
326
|
+
await testdriver.pressKeys(['ctrl', 'l']);
|
|
327
|
+
await testdriver.type('https://example.com');
|
|
328
|
+
await testdriver.pressKeys(['enter']);
|
|
329
|
+
|
|
330
|
+
await new Promise(r => setTimeout(r, 2000));
|
|
331
|
+
|
|
332
|
+
// Select all page content
|
|
333
|
+
await testdriver.pressKeys(['ctrl', 'a']);
|
|
334
|
+
|
|
335
|
+
// Copy
|
|
336
|
+
await testdriver.pressKeys(['ctrl', 'c']);
|
|
337
|
+
|
|
338
|
+
// Refresh page
|
|
339
|
+
await testdriver.pressKeys(['f5']);
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
## Related Methods
|
|
345
|
+
|
|
346
|
+
- [`type()`](/v7/type) - Type text
|
|
347
|
+
- [`click()`](/v7/click) - Click elements
|
|
348
|
+
- [`scroll()`](/v7/scroll) - Scroll pages
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testdriver:quickstart
|
|
3
|
+
description: Run your first computer-use test in minutes.
|
|
4
|
+
---
|
|
5
|
+
<!-- Generated from quickstart.mdx. DO NOT EDIT. -->
|
|
6
|
+
|
|
7
|
+
TestDriver makes it easy to write automated computer-use tests for web browsers, desktop apps, and more. Follow the directions below to run your first TestDriver test.
|
|
8
|
+
|
|
9
|
+
<Tip><a href="https://discord.com/invite/cWDFW8DzPm" target="_blank" rel="noreferrer">Join our Discord</a> if you have any questions or need help getting started!</Tip>
|
|
10
|
+
|
|
11
|
+
<Tabs>
|
|
12
|
+
<Tab title="Automatic Setup">
|
|
13
|
+
|
|
14
|
+
Get started quickly with the TestDriver CLI.
|
|
15
|
+
|
|
16
|
+
<Steps>
|
|
17
|
+
<Step title="Install TestDriver">
|
|
18
|
+
|
|
19
|
+
Use `npx` to quickly set up an example project:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx testdriverai init
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This will walk you through creating a new project folder, installing dependencies, and setting up your API key.
|
|
26
|
+
|
|
27
|
+
</Step>
|
|
28
|
+
|
|
29
|
+
<Step title="Run Your Test">
|
|
30
|
+
|
|
31
|
+
TestDriver uses Vitest as the test runner. To run your test, use:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
vitest run
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This will spawn a sandbox, launch Chrome, and run the example test!
|
|
38
|
+
|
|
39
|
+
</Step>
|
|
40
|
+
</Steps>
|
|
41
|
+
</Tab>
|
|
42
|
+
<Tab title="Manual Setup">
|
|
43
|
+
|
|
44
|
+
Install TestDriver and manually create the files yourself.
|
|
45
|
+
|
|
46
|
+
<Steps>
|
|
47
|
+
<Step title="Create a TestDriver Account">
|
|
48
|
+
|
|
49
|
+
You will need a TestDriver account to get an API key.
|
|
50
|
+
|
|
51
|
+
<Card
|
|
52
|
+
title="Get an API Key"
|
|
53
|
+
icon="user-plus"
|
|
54
|
+
href="https://console.testdriver.ai/team"
|
|
55
|
+
arrow
|
|
56
|
+
horizontal
|
|
57
|
+
>
|
|
58
|
+
Start with 60 free device minutes, no credit-card required!
|
|
59
|
+
</Card>
|
|
60
|
+
|
|
61
|
+
</Step>
|
|
62
|
+
<Step title="Install Dependencies">
|
|
63
|
+
|
|
64
|
+
Install Vitest and TestDriver as dev dependencies:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm install --save-dev vitest testdriverai
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
</Step>
|
|
71
|
+
<Step title="Create a vitest.config.js File">
|
|
72
|
+
|
|
73
|
+
In your project root, create a `vitest.config.js` file with the following content:
|
|
74
|
+
|
|
75
|
+
```js vitest.config.js
|
|
76
|
+
import TestDriver from 'testdriverai/vitest';
|
|
77
|
+
import { defineConfig } from 'vitest/config';
|
|
78
|
+
|
|
79
|
+
export default defineConfig({
|
|
80
|
+
test: {
|
|
81
|
+
testTimeout: 900000,
|
|
82
|
+
hookTimeout: 900000,
|
|
83
|
+
disableConsoleIntercept: true,
|
|
84
|
+
maxConcurrency: 1, // this should match your plan's concurrency limit
|
|
85
|
+
reporters: [
|
|
86
|
+
'default',
|
|
87
|
+
TestDriver()
|
|
88
|
+
],
|
|
89
|
+
setupFiles: ['testdriverai/vitest/setup'],
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
</Step>
|
|
95
|
+
<Step title="Create an Example Test File">
|
|
96
|
+
|
|
97
|
+
Add your API key to the example test file below and save it as `test.mjs` in your project root.
|
|
98
|
+
|
|
99
|
+
```js test.mjs highlight={9}
|
|
100
|
+
import { describe, expect, it } from "vitest";
|
|
101
|
+
// Import TestDriver from the vitest hooks
|
|
102
|
+
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
103
|
+
|
|
104
|
+
describe("Google Search Example", () => {
|
|
105
|
+
it("should search for TestDriver", async (context) => {
|
|
106
|
+
// Create TestDriver instance - automatically connects to sandbox
|
|
107
|
+
const testdriver = TestDriver(context, {
|
|
108
|
+
apiKey: 'YOUR_API_KEY_HERE' // supply your API key here
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Provision Chrome browser with a URL
|
|
112
|
+
// This also starts dashcam recording automatically
|
|
113
|
+
await testdriver.provision.chrome({ url: "https://duckduckgo.com" });
|
|
114
|
+
|
|
115
|
+
// Find and interact with elements using natural language
|
|
116
|
+
const searchBox = await testdriver.find("DuckDuckGo search input field");
|
|
117
|
+
await searchBox.click();
|
|
118
|
+
|
|
119
|
+
// Type into the focused element
|
|
120
|
+
await testdriver.type("testdriver.ai");
|
|
121
|
+
|
|
122
|
+
// Press Enter to search
|
|
123
|
+
await testdriver.pressKeys(["enter"]);
|
|
124
|
+
|
|
125
|
+
// Assert something is visible on the page
|
|
126
|
+
const result = await testdriver.assert("search results are displayed");
|
|
127
|
+
expect(result).toBeTruthy();
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
</Step>
|
|
133
|
+
<Step title="Run Your Test">
|
|
134
|
+
|
|
135
|
+
TestDriver uses Vitest as the test runner. To run your test, use:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
vitest run
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
This will spawn a sandbox, launch Chrome, and run the example test!
|
|
142
|
+
|
|
143
|
+
</Step>
|
|
144
|
+
</Steps>
|
|
145
|
+
</Tab>
|
|
146
|
+
</Tabs>
|