@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
package/docs/click.mdx CHANGED
@@ -1,287 +1,132 @@
1
1
  ---
2
2
  title: "click()"
3
3
  sidebarTitle: "click"
4
- description: "Click at specific coordinates or on elements"
4
+ description: "Click an element you found, or click a point on the screen."
5
5
  icon: "mouse-pointer"
6
6
  ---
7
7
 
8
- ## Element Click
9
-
10
- When you call this on an Element object, it clicks on the found element.
11
-
12
- ### Syntax
8
+ Click an element you've located with [`find()`](/find):
13
9
 
14
10
  ```javascript
15
- await element.click(action)
11
+ const signInButton = await testdriver.find('Sign in button');
12
+ await signInButton.click();
16
13
  ```
17
14
 
18
- ### Parameters
19
-
20
- <ParamField path="action" type="string" default="click">
21
- Type of click action: `'click'`, `'double-click'`, `'right-click'`, `'hover'`, `'mouseDown'`, `'mouseUp'`
22
- </ParamField>
23
-
24
- ### Returns
25
-
26
- `Promise<void>`
27
-
28
- ### Examples
15
+ Or chain it straight onto `find()`:
29
16
 
30
17
  ```javascript
31
- // Regular click
32
- const button = await testdriver.find('submit button');
33
- await button.click();
34
-
35
- // Double-click
36
- const file = await testdriver.find('README.txt file');
37
- await file.click('double-click');
38
-
39
- // Right-click
40
- const item = await testdriver.find('menu item');
41
- await item.click('right-click');
42
-
43
- // Hover (same as element.hover())
44
- const tooltip = await testdriver.find('info icon');
45
- await button.click('hover');
18
+ await testdriver.find('Sign in button').click();
46
19
  ```
47
20
 
48
- ## Coordinate Click
21
+ ## element.click(action)
49
22
 
50
- Click at specific screen coordinates.
23
+ Clicks the element at the point where `find()` located it.
51
24
 
52
- ### Syntax
53
-
54
- ```javascript
55
- await testdriver.click(x, y, action)
25
+ ```typescript
26
+ element.click(action?: ClickAction): Promise<void>
56
27
  ```
57
28
 
58
29
  ### Parameters
59
30
 
60
- <ParamField path="x" type="number" required>
61
- X coordinate
62
- </ParamField>
63
-
64
- <ParamField path="y" type="number" required>
65
- Y coordinate
66
- </ParamField>
31
+ <ParamField path="action" type="ClickAction" default="click">
32
+ The mouse action to perform:
67
33
 
68
- <ParamField path="action" type="string" default="click">
69
- Type of click: `'click'`, `'double-click'`, `'right-click'`, `'mouseDown'`, `'mouseUp'`
34
+ - `'click'`: a left click
35
+ - `'double-click'`: a double click, same as [`doubleClick()`](/double-click)
36
+ - `'right-click'`: a right click, same as [`rightClick()`](/right-click)
37
+ - `'hover'`: move the mouse there without clicking, same as [`hover()`](/hover)
38
+ - `'mouseDown'` and `'mouseUp'`: press or release the button, for dragging. See [mouseDown()](/mouse-down).
70
39
  </ParamField>
71
40
 
72
- ### Returns
73
-
74
- `Promise<void>`
41
+ ### Errors
75
42
 
76
- ### Examples
43
+ Throws an `ElementNotFoundError` if `find()` didn't locate the element. Check `found()` first when the element might not be there:
77
44
 
78
45
  ```javascript
79
- // Click at coordinates
80
- await testdriver.click(500, 300);
81
-
82
- // Double-click at coordinates
83
- await testdriver.click(500, 300, 'double-click');
84
-
85
- // Right-click at coordinates
86
- await testdriver.click(500, 300, 'right-click');
46
+ const banner = await testdriver.find('cookie consent banner', { timeout: 0 });
47
+ if (banner.found()) {
48
+ await testdriver.find('Accept all cookies button').click();
49
+ }
87
50
  ```
88
51
 
89
- ## Click Actions
52
+ ## testdriver.click(options)
90
53
 
91
- ### Regular Click
54
+ Clicks a point on the screen by its coordinates. Prefer `element.click()`, which keeps working when the layout or screen size changes.
92
55
 
93
- One left-click action.
94
-
95
- ```javascript
96
- const button = await testdriver.find('Login button');
97
- await button.click();
56
+ ```typescript
57
+ testdriver.click(options: { x: number; y: number; action?: ClickAction }): Promise<void>
98
58
  ```
99
59
 
100
- ### Double Click
60
+ ### Parameters
101
61
 
102
- A double-click action. It usually opens files or selects text.
62
+ <ParamField path="options" type="object" required>
63
+ <Expandable title="properties">
64
+ <ParamField path="x" type="number" required>
65
+ Distance from the left edge of the screen, in pixels.
66
+ </ParamField>
67
+ <ParamField path="y" type="number" required>
68
+ Distance from the top edge of the screen, in pixels.
69
+ </ParamField>
70
+ <ParamField path="action" type="ClickAction" default="click">
71
+ The mouse action, as for `element.click()`. `'hover'` doesn't move the mouse here; use [`testdriver.hover({ x, y })`](/hover) instead.
72
+ </ParamField>
73
+ </Expandable>
74
+ </ParamField>
103
75
 
104
76
  ```javascript
105
- const file = await testdriver.find('document.pdf');
106
- await file.click('double-click');
107
-
108
- // Or use the dedicated method
109
- await file.doubleClick();
77
+ await testdriver.click({ x: 640, y: 360 });
78
+ await testdriver.click({ x: 640, y: 360, action: 'right-click' });
110
79
  ```
111
80
 
112
- ### Right Click
81
+ <Note>
82
+ The older form `testdriver.click(x, y, action)` still works. Use the options object in new tests.
83
+ </Note>
113
84
 
114
- Right-click to open context menus.
85
+ ## Examples
115
86
 
116
- ```javascript
117
- const folder = await testdriver.find('Documents folder');
118
- await folder.click('right-click');
87
+ ### Open a context menu
119
88
 
120
- // Or use the dedicated method
121
- await folder.rightClick();
89
+ ```javascript
90
+ await testdriver.find('report.pdf in the file list').click('right-click');
91
+ await testdriver.find('Rename in the context menu').click();
122
92
  ```
123
93
 
124
- ### Mouse Down / Mouse Up
125
-
126
- Use these for drag operations or custom click behavior.
94
+ ### Open a file
127
95
 
128
96
  ```javascript
129
- const draggable = await testdriver.find('draggable item');
130
- await draggable.click('mouseDown');
131
-
132
- // Move to target
133
- const dropZone = await testdriver.find('drop zone');
134
- await dropZone.hover();
135
- await dropZone.click('mouseUp');
136
-
137
- // Or use dedicated methods
138
- await draggable.mouseDown();
139
- await dropZone.mouseUp();
97
+ await testdriver.find('report.pdf in the file list').click('double-click');
140
98
  ```
141
99
 
142
- ## Best Practices
143
-
144
- <Check>
145
- **Prefer element clicks to coordinate clicks**
146
-
147
- A click on an element is more reliable. It does not depend on the resolution:
148
-
149
- ```javascript
150
- // ✅ Preferred
151
- const button = await testdriver.find('submit button');
152
- await button.click();
153
-
154
- // ❌ Avoid (fragile)
155
- await testdriver.click(500, 300);
156
- ```
157
- </Check>
158
-
159
- <Check>
160
- **Make sure that TestDriver found the element**
161
-
162
- ```javascript
163
- const element = await testdriver.find('button');
164
- if (!element.found()) {
165
- throw new Error('Element not found');
166
- }
167
- await element.click();
168
- ```
169
- </Check>
170
-
171
- <Warning>
172
- **TestDriver must find the element before you click it**
173
-
174
- The `find()` method finds elements automatically. But a click on an element that TestDriver did not find throws an error:
175
-
176
- ```javascript
177
- const element = await testdriver.find('button');
178
- // This will throw if element wasn't found
179
- await element.click();
180
- ```
181
- </Warning>
182
-
183
- ## Use Cases
184
-
185
- <AccordionGroup>
186
- <Accordion title="Button Clicks">
187
- ```javascript
188
- const submitBtn = await testdriver.find('submit button');
189
- await submitBtn.click();
190
-
191
- const cancelBtn = await testdriver.find('cancel button');
192
- await cancelBtn.click();
193
- ```
194
- </Accordion>
195
-
196
- <Accordion title="Opening Files">
197
- ```javascript
198
- const file = await testdriver.find('report.pdf file icon');
199
- await file.doubleClick();
200
- ```
201
- </Accordion>
202
-
203
- <Accordion title="Context Menus">
204
- ```javascript
205
- const item = await testdriver.find('file item');
206
- await item.rightClick();
207
-
208
- // Select menu option
209
- const deleteOption = await testdriver.find('Delete option');
210
- await deleteOption.click();
211
- ```
212
- </Accordion>
213
-
214
- <Accordion title="Drag and Drop">
215
- ```javascript
216
- const source = await testdriver.find('source item');
217
- await source.mouseDown();
218
-
219
- const target = await testdriver.find('target zone');
220
- await target.hover();
221
- await target.mouseUp();
222
- ```
223
- </Accordion>
224
- </AccordionGroup>
225
-
226
- ## Complete Example
100
+ ### Drag an item
227
101
 
228
102
  ```javascript
229
- import { beforeAll, afterAll, describe, it } from 'vitest';
230
- import TestDriver from 'testdriverai';
103
+ await testdriver.find('Task card titled "Write docs"').mouseDown();
104
+ await testdriver.find('Done column').hover();
105
+ await testdriver.find('Done column').mouseUp();
106
+ ```
231
107
 
232
- describe('Click Interactions', () => {
233
- let testdriver;
108
+ ## Complete example
234
109
 
235
- beforeAll(async () => {
236
- client = new TestDriver(process.env.TD_API_KEY);
237
- await testdriver.auth();
238
- await testdriver.connect();
239
- });
110
+ ```javascript tests/login.test.mjs
111
+ import { describe, expect, it } from 'vitest';
112
+ import { TestDriver } from 'testdriverai/vitest/hooks';
240
113
 
241
- afterAll(async () => {
242
- await testdriver.disconnect();
243
- });
114
+ describe('Login', () => {
115
+ it('shows an error for an empty form', async (context) => {
116
+ const testdriver = TestDriver(context);
117
+ await testdriver.provision.chrome({ url: 'https://testdriver-sandbox.vercel.app/login' });
244
118
 
245
- it('should perform various click actions', async () => {
246
- await testdriver.focusApplication('Google Chrome');
247
-
248
- // Regular click
249
- const loginBtn = await testdriver.find('login button');
250
- await loginBtn.click();
251
-
252
- // Right-click for context menu
253
- const profileIcon = await testdriver.find('profile icon');
254
- await profileIcon.rightClick();
255
-
256
- const settingsOption = await testdriver.find('Settings menu option');
257
- await settingsOption.click();
258
-
259
- // Double-click to edit
260
- const nameField = await testdriver.find('name display field');
261
- await nameField.doubleClick();
262
-
263
- // Verify state
264
- await testdriver.assert('name field is now editable');
265
- });
119
+ await testdriver.find('Sign in button below the password field').click();
266
120
 
267
- it('should perform drag and drop', async () => {
268
- const item = await testdriver.find('draggable item');
269
- await item.mouseDown();
270
-
271
- // Drag to new location
272
- const dropTarget = await testdriver.find('drop area');
273
- await dropTarget.hover();
274
- await dropTarget.mouseUp();
275
-
276
- // Verify
277
- await testdriver.assert('item is in the drop area');
121
+ const result = await testdriver.assert('an error says the fields are required');
122
+ expect(result).toBe(true);
278
123
  });
279
124
  });
280
125
  ```
281
126
 
282
- ## Related Methods
127
+ ## Related
283
128
 
284
- - [`find()`](/find) - Find elements to click
285
- - [`hover()`](/hover) - Put the cursor on the element without a click
286
- - [`doubleClick()`](/double-click) - The double-click method
287
- - [`rightClick()`](/right-click) - The right-click method
129
+ - [find()](/find): locate the element to click
130
+ - [doubleClick()](/double-click), [rightClick()](/right-click), and [hover()](/hover): shortcuts for the other actions
131
+ - [mouseDown()](/mouse-down) and [mouseUp()](/mouse-up): drag and drop
132
+ - [Perform actions](/performing-actions): every kind of action in one guide