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