testdriverai 7.0.0 → 7.1.0
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/AGENTS.md +550 -0
- package/CODEOWNERS +0 -1
- package/README.md +126 -0
- package/agent/index.js +43 -18
- package/agent/lib/commands.js +794 -135
- package/agent/lib/redraw.js +124 -39
- package/agent/lib/sandbox.js +10 -1
- package/agent/lib/sdk.js +21 -0
- package/docs/MIGRATION.md +425 -0
- package/docs/PRESETS.md +210 -0
- package/docs/docs.json +91 -37
- package/docs/guide/best-practices-polling.mdx +154 -0
- package/docs/v7/api/dashcam.mdx +497 -0
- package/docs/v7/api/doubleClick.mdx +102 -0
- package/docs/v7/api/mouseDown.mdx +161 -0
- package/docs/v7/api/mouseUp.mdx +164 -0
- package/docs/v7/api/rightClick.mdx +123 -0
- package/docs/v7/getting-started/configuration.mdx +380 -0
- package/docs/v7/getting-started/quickstart.mdx +273 -140
- package/docs/v7/guides/best-practices.mdx +486 -0
- package/docs/v7/guides/caching-ai.mdx +215 -0
- package/docs/v7/guides/caching-selectors.mdx +292 -0
- package/docs/v7/guides/caching.mdx +366 -0
- package/docs/v7/guides/ci-cd/azure.mdx +587 -0
- package/docs/v7/guides/ci-cd/circleci.mdx +523 -0
- package/docs/v7/guides/ci-cd/github-actions.mdx +457 -0
- package/docs/v7/guides/ci-cd/gitlab.mdx +498 -0
- package/docs/v7/guides/ci-cd/jenkins.mdx +664 -0
- package/docs/v7/guides/ci-cd/travis.mdx +438 -0
- package/docs/v7/guides/debugging.mdx +349 -0
- package/docs/v7/guides/faq.mdx +393 -0
- package/docs/v7/guides/performance.mdx +517 -0
- package/docs/v7/guides/troubleshooting.mdx +526 -0
- package/docs/v7/guides/vitest-plugin.mdx +477 -0
- package/docs/v7/guides/vitest.mdx +535 -0
- package/docs/v7/platforms/linux.mdx +308 -0
- package/docs/v7/platforms/macos.mdx +433 -0
- package/docs/v7/platforms/windows.mdx +430 -0
- package/docs/v7/presets/chrome-extension.mdx +223 -0
- package/docs/v7/presets/chrome.mdx +287 -0
- package/docs/v7/presets/electron.mdx +435 -0
- package/docs/v7/presets/vscode.mdx +398 -0
- package/docs/v7/presets/webapp.mdx +396 -0
- package/docs/v7/progressive-apis/CORE.md +459 -0
- package/docs/v7/progressive-apis/HOOKS.md +360 -0
- package/docs/v7/progressive-apis/PROGRESSIVE_DISCLOSURE.md +230 -0
- package/docs/v7/progressive-apis/PROVISION.md +266 -0
- package/interfaces/vitest-plugin.mjs +186 -100
- package/package.json +12 -1
- package/sdk.d.ts +335 -42
- package/sdk.js +756 -95
- package/src/core/Dashcam.js +469 -0
- package/src/core/index.d.ts +150 -0
- package/src/core/index.js +12 -0
- package/src/presets/index.mjs +331 -0
- package/src/vitest/extended.mjs +108 -0
- package/src/vitest/hooks.d.ts +119 -0
- package/src/vitest/hooks.mjs +298 -0
- package/src/vitest/index.mjs +64 -0
- package/src/vitest/lifecycle.mjs +277 -0
- package/src/vitest/utils.mjs +150 -0
- package/test/dashcam.test.js +137 -0
- package/testdriver/acceptance-sdk/assert.test.mjs +13 -31
- package/testdriver/acceptance-sdk/auto-cache-key-demo.test.mjs +56 -0
- package/testdriver/acceptance-sdk/chrome-extension.test.mjs +89 -0
- package/testdriver/acceptance-sdk/drag-and-drop.test.mjs +7 -19
- package/testdriver/acceptance-sdk/element-not-found.test.mjs +6 -19
- package/testdriver/acceptance-sdk/exec-js.test.mjs +6 -18
- package/testdriver/acceptance-sdk/exec-output.test.mjs +8 -20
- package/testdriver/acceptance-sdk/exec-pwsh.test.mjs +13 -25
- package/testdriver/acceptance-sdk/focus-window.test.mjs +8 -20
- package/testdriver/acceptance-sdk/formatted-logging.test.mjs +5 -20
- package/testdriver/acceptance-sdk/hooks-example.test.mjs +38 -0
- package/testdriver/acceptance-sdk/hover-image.test.mjs +10 -19
- package/testdriver/acceptance-sdk/hover-text-with-description.test.mjs +7 -19
- package/testdriver/acceptance-sdk/hover-text.test.mjs +5 -19
- package/testdriver/acceptance-sdk/match-image.test.mjs +7 -19
- package/testdriver/acceptance-sdk/presets-example.test.mjs +87 -0
- package/testdriver/acceptance-sdk/press-keys.test.mjs +5 -19
- package/testdriver/acceptance-sdk/prompt.test.mjs +6 -18
- package/testdriver/acceptance-sdk/scroll-keyboard.test.mjs +6 -20
- package/testdriver/acceptance-sdk/scroll-until-image.test.mjs +6 -18
- package/testdriver/acceptance-sdk/scroll-until-text.test.mjs +9 -23
- package/testdriver/acceptance-sdk/scroll.test.mjs +12 -21
- package/testdriver/acceptance-sdk/setup/testHelpers.mjs +124 -352
- package/testdriver/acceptance-sdk/sully-ai.test.mjs +234 -0
- package/testdriver/acceptance-sdk/test-console-logs.test.mjs +42 -0
- package/testdriver/acceptance-sdk/type.test.mjs +19 -58
- package/vitest.config.mjs +1 -0
- package/.vscode/mcp.json +0 -9
- package/MIGRATION.md +0 -389
- package/PLUGIN_MIGRATION.md +0 -222
- package/PROMPT_CACHE.md +0 -200
- package/SDK_LOGGING.md +0 -222
- package/SDK_MIGRATION.md +0 -474
- package/SDK_README.md +0 -1122
- package/debug-screenshot-1763401388589.png +0 -0
- package/examples/run-tests-with-recording.sh +0 -70
- package/examples/screenshot-example.js +0 -63
- package/examples/sdk-awesome-logs-demo.js +0 -177
- package/examples/sdk-cache-thresholds.js +0 -96
- package/examples/sdk-element-properties.js +0 -155
- package/examples/sdk-simple-example.js +0 -65
- package/examples/test-recording-example.test.js +0 -166
- package/mcp-server/AI_GUIDELINES.md +0 -57
- package/test-find-api.js +0 -73
- package/test-prompt-cache.js +0 -96
- package/test-sandbox-render.js +0 -28
- package/test-sdk-methods.js +0 -15
- package/test-sdk-refactor.js +0 -53
- package/test-stack-trace.mjs +0 -57
- package/testdriver/acceptance-sdk/setup/lifecycleHelpers.mjs +0 -239
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "mouseDown"
|
|
3
|
+
description: "Press the mouse button without releasing it"
|
|
4
|
+
icon: "arrow-pointer"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
The `mouseDown()` method presses the mouse button at an element's location without releasing it. This is useful for drag operations, custom gestures, or when you need precise control over mouse events. 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
|
+
// Mouse down on an element
|
|
15
|
+
await element.mouseDown();
|
|
16
|
+
|
|
17
|
+
// Mouse down using a selector
|
|
18
|
+
await ai.mouseDown('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 where the mouse button should be pressed |
|
|
30
|
+
|
|
31
|
+
## Returns
|
|
32
|
+
|
|
33
|
+
Returns a `Promise<void>` that resolves when the mouse button is pressed.
|
|
34
|
+
|
|
35
|
+
## Examples
|
|
36
|
+
|
|
37
|
+
### Basic Drag Operation
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
// Start dragging an item
|
|
41
|
+
const dragItem = await ai.find('file to drag');
|
|
42
|
+
await dragItem.mouseDown();
|
|
43
|
+
|
|
44
|
+
// Move to drop target
|
|
45
|
+
const dropTarget = await ai.find('folder to drop into');
|
|
46
|
+
await dropTarget.hover();
|
|
47
|
+
|
|
48
|
+
// Release
|
|
49
|
+
await ai.mouseUp();
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Drag and Drop with Direct Selectors
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
await ai.mouseDown('draggable card');
|
|
56
|
+
await ai.hover('drop zone');
|
|
57
|
+
await ai.mouseUp();
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Selecting Multiple Items
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
import { test } from 'vitest';
|
|
64
|
+
import { chrome } from '@testdriver/sdk';
|
|
65
|
+
|
|
66
|
+
test('selects multiple items with click and drag', async () => {
|
|
67
|
+
const { ai } = await chrome('https://app.example.com');
|
|
68
|
+
|
|
69
|
+
// Start selection at first item
|
|
70
|
+
await ai.mouseDown('first item in grid');
|
|
71
|
+
|
|
72
|
+
// Drag to last item
|
|
73
|
+
await ai.hover('last item in grid');
|
|
74
|
+
|
|
75
|
+
// Release to complete selection
|
|
76
|
+
await ai.mouseUp();
|
|
77
|
+
|
|
78
|
+
// Verify multiple items selected
|
|
79
|
+
const selectedItems = await ai.find('selected items count');
|
|
80
|
+
expect(selectedItems.text).toContain('5 items selected');
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Custom Drawing Application
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
test('draws on canvas', async () => {
|
|
88
|
+
const { ai } = await chrome('https://drawing-app.example.com');
|
|
89
|
+
|
|
90
|
+
// Start drawing
|
|
91
|
+
await ai.mouseDown('canvas at top-left corner');
|
|
92
|
+
|
|
93
|
+
// Draw a line by moving mouse
|
|
94
|
+
await ai.hover('canvas at center');
|
|
95
|
+
await ai.hover('canvas at bottom-right corner');
|
|
96
|
+
|
|
97
|
+
// Stop drawing
|
|
98
|
+
await ai.mouseUp();
|
|
99
|
+
|
|
100
|
+
// Verify something was drawn
|
|
101
|
+
const canvas = await ai.exec('document.querySelector("canvas").toDataURL()');
|
|
102
|
+
expect(canvas).toBeTruthy();
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Long Press Gesture
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
test('triggers long press menu', async () => {
|
|
110
|
+
const { ai } = await chrome('https://mobile-app.example.com');
|
|
111
|
+
|
|
112
|
+
// Press and hold
|
|
113
|
+
await ai.mouseDown('message in chat');
|
|
114
|
+
|
|
115
|
+
// Wait for long-press menu
|
|
116
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
117
|
+
|
|
118
|
+
// Verify menu appeared before releasing
|
|
119
|
+
const menu = await ai.find('message options menu');
|
|
120
|
+
expect(menu).toBeTruthy();
|
|
121
|
+
|
|
122
|
+
// Release
|
|
123
|
+
await ai.mouseUp();
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Resizing UI Elements
|
|
128
|
+
|
|
129
|
+
```javascript
|
|
130
|
+
test('resizes panel', async () => {
|
|
131
|
+
const { ai } = await vscode();
|
|
132
|
+
|
|
133
|
+
// Grab resize handle
|
|
134
|
+
await ai.mouseDown('sidebar resize handle');
|
|
135
|
+
|
|
136
|
+
// Drag to new position
|
|
137
|
+
await ai.hover('position 300 pixels from left edge');
|
|
138
|
+
|
|
139
|
+
// Release
|
|
140
|
+
await ai.mouseUp();
|
|
141
|
+
|
|
142
|
+
// Verify new size
|
|
143
|
+
const sidebar = await ai.find('sidebar');
|
|
144
|
+
expect(sidebar.width).toBeGreaterThan(250);
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Important Notes
|
|
149
|
+
|
|
150
|
+
- Always pair `mouseDown()` with [`mouseUp()`](/v7/api/mouseUp) to complete the gesture
|
|
151
|
+
- The mouse button remains pressed until `mouseUp()` is called
|
|
152
|
+
- Use [`hover()`](/v7/api/hover) to move the mouse while the button is pressed
|
|
153
|
+
- For simple drag operations, consider using `ai()` with a natural language description like `"drag file to folder"`
|
|
154
|
+
|
|
155
|
+
## Related Methods
|
|
156
|
+
|
|
157
|
+
- [`mouseUp()`](/v7/api/mouseUp) - Release the mouse button
|
|
158
|
+
- [`hover()`](/v7/api/hover) - Move mouse to element
|
|
159
|
+
- [`click()`](/v7/api/click) - Full click (mouseDown + mouseUp)
|
|
160
|
+
- [`doubleClick()`](/v7/api/doubleClick) - Double-click on element
|
|
161
|
+
- [`rightClick()`](/v7/api/rightClick) - Right-click for context menu
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "mouseUp"
|
|
3
|
+
description: "Release the mouse button"
|
|
4
|
+
icon: "arrow-pointer"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
The `mouseUp()` method releases the mouse button, completing a drag operation or custom mouse gesture that was started with [`mouseDown()`](/v7/api/mouseDown). You can call it without parameters to release at the current mouse position.
|
|
10
|
+
|
|
11
|
+
## Syntax
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
// Release mouse button at current position
|
|
15
|
+
await ai.mouseUp();
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Parameters
|
|
19
|
+
|
|
20
|
+
None. The mouse button is released at the current cursor position.
|
|
21
|
+
|
|
22
|
+
## Returns
|
|
23
|
+
|
|
24
|
+
Returns a `Promise<void>` that resolves when the mouse button is released.
|
|
25
|
+
|
|
26
|
+
## Examples
|
|
27
|
+
|
|
28
|
+
### Complete Drag and Drop
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
// Start dragging
|
|
32
|
+
await ai.mouseDown('file to drag');
|
|
33
|
+
|
|
34
|
+
// Move to drop location
|
|
35
|
+
await ai.hover('target folder');
|
|
36
|
+
|
|
37
|
+
// Complete the drop
|
|
38
|
+
await ai.mouseUp();
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Selecting Multiple Files
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
import { test } from 'vitest';
|
|
45
|
+
import { vscode } from '@testdriver/sdk';
|
|
46
|
+
|
|
47
|
+
test('selects range of files', async () => {
|
|
48
|
+
const { ai } = await vscode();
|
|
49
|
+
|
|
50
|
+
// Click first file
|
|
51
|
+
await ai.click('first-file.js in explorer');
|
|
52
|
+
|
|
53
|
+
// Hold shift and click last file
|
|
54
|
+
await ai.pressKeys('Shift');
|
|
55
|
+
await ai.mouseDown('last-file.js in explorer');
|
|
56
|
+
await ai.mouseUp();
|
|
57
|
+
|
|
58
|
+
// Verify multiple files selected
|
|
59
|
+
const selectedCount = await ai.find('status bar showing file count');
|
|
60
|
+
expect(selectedCount.text).toContain('5 files');
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Drawing Application
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
test('draws a shape', async () => {
|
|
68
|
+
const { ai } = await chrome('https://drawing-app.example.com');
|
|
69
|
+
|
|
70
|
+
// Select pencil tool
|
|
71
|
+
await ai.click('pencil tool');
|
|
72
|
+
|
|
73
|
+
// Draw a line
|
|
74
|
+
await ai.mouseDown('canvas near top-left');
|
|
75
|
+
await ai.hover('canvas center');
|
|
76
|
+
await ai.hover('canvas bottom-right');
|
|
77
|
+
await ai.mouseUp();
|
|
78
|
+
|
|
79
|
+
// Verify drawing exists
|
|
80
|
+
const strokes = await ai.exec('canvas.getContext("2d").getImageData(0,0,100,100)');
|
|
81
|
+
expect(strokes).toBeTruthy();
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Resizing Window Panels
|
|
86
|
+
|
|
87
|
+
```javascript
|
|
88
|
+
test('resizes editor panel', async () => {
|
|
89
|
+
const { ai } = await vscode();
|
|
90
|
+
|
|
91
|
+
// Grab the divider
|
|
92
|
+
await ai.mouseDown('panel resize divider');
|
|
93
|
+
|
|
94
|
+
// Drag to new position
|
|
95
|
+
await ai.hover('position 400 pixels from left');
|
|
96
|
+
|
|
97
|
+
// Release to complete resize
|
|
98
|
+
await ai.mouseUp();
|
|
99
|
+
|
|
100
|
+
// Verify new panel size
|
|
101
|
+
const panel = await ai.find('editor panel');
|
|
102
|
+
expect(panel.width).toBeGreaterThan(350);
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Drag to Reorder List Items
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
import { test } from 'vitest';
|
|
110
|
+
import { chrome } from '@testdriver/sdk';
|
|
111
|
+
|
|
112
|
+
test('reorders tasks in list', async () => {
|
|
113
|
+
const { ai } = await chrome('https://todo-app.example.com');
|
|
114
|
+
|
|
115
|
+
// Start dragging first task
|
|
116
|
+
await ai.mouseDown('drag handle on first task');
|
|
117
|
+
|
|
118
|
+
// Move down to third position
|
|
119
|
+
await ai.hover('third task position');
|
|
120
|
+
|
|
121
|
+
// Drop the task
|
|
122
|
+
await ai.mouseUp();
|
|
123
|
+
|
|
124
|
+
// Verify new order
|
|
125
|
+
const thirdTask = await ai.find('third task in list');
|
|
126
|
+
expect(thirdTask.text).toContain('Original first task');
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Text Selection with Mouse
|
|
131
|
+
|
|
132
|
+
```javascript
|
|
133
|
+
test('selects text with mouse drag', async () => {
|
|
134
|
+
const { ai } = await chrome('https://document.example.com');
|
|
135
|
+
|
|
136
|
+
// Start selection at beginning of word
|
|
137
|
+
await ai.mouseDown('start of "TestDriver" word');
|
|
138
|
+
|
|
139
|
+
// Drag to end of word
|
|
140
|
+
await ai.hover('end of "TestDriver" word');
|
|
141
|
+
|
|
142
|
+
// Complete selection
|
|
143
|
+
await ai.mouseUp();
|
|
144
|
+
|
|
145
|
+
// Verify selection
|
|
146
|
+
const selection = await ai.exec('window.getSelection().toString()');
|
|
147
|
+
expect(selection).toBe('TestDriver');
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Important Notes
|
|
152
|
+
|
|
153
|
+
- `mouseUp()` must be preceded by [`mouseDown()`](/v7/api/mouseDown) to have an effect
|
|
154
|
+
- Releases the button at the current cursor position
|
|
155
|
+
- Completes any drag or selection operation that was in progress
|
|
156
|
+
- For simple clicks, use [`click()`](/v7/api/click) instead of mouseDown/mouseUp pair
|
|
157
|
+
|
|
158
|
+
## Related Methods
|
|
159
|
+
|
|
160
|
+
- [`mouseDown()`](/v7/api/mouseDown) - Press mouse button without releasing
|
|
161
|
+
- [`hover()`](/v7/api/hover) - Move mouse to element
|
|
162
|
+
- [`click()`](/v7/api/click) - Complete click (mouseDown + mouseUp)
|
|
163
|
+
- [`doubleClick()`](/v7/api/doubleClick) - Double-click on element
|
|
164
|
+
- [`rightClick()`](/v7/api/rightClick) - Right-click for context menu
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "rightClick"
|
|
3
|
+
description: "Perform a right-click action to open context menus"
|
|
4
|
+
icon: "bars"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
The `rightClick()` method performs a right-click action on an element, typically used to open context menus. 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
|
+
// Right-click on an element
|
|
15
|
+
await element.rightClick();
|
|
16
|
+
|
|
17
|
+
// Right-click using a selector
|
|
18
|
+
await ai.rightClick('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 right-click |
|
|
30
|
+
|
|
31
|
+
## Returns
|
|
32
|
+
|
|
33
|
+
Returns a `Promise<void>` that resolves when the right-click action completes.
|
|
34
|
+
|
|
35
|
+
## Examples
|
|
36
|
+
|
|
37
|
+
### Right-Click to Open Context Menu
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
const fileItem = await ai.find('README.md file');
|
|
41
|
+
await fileItem.rightClick();
|
|
42
|
+
|
|
43
|
+
// Select menu option
|
|
44
|
+
await ai.click('Delete from context menu');
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Direct Right-Click with Selector
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
await ai.rightClick('image in the gallery');
|
|
51
|
+
await ai.click('Save image as');
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### VS Code Context Menu
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
import { test } from 'vitest';
|
|
58
|
+
import { vscode } from '@testdriver/sdk';
|
|
59
|
+
|
|
60
|
+
test('renames a file via context menu', async () => {
|
|
61
|
+
const { ai } = await vscode();
|
|
62
|
+
|
|
63
|
+
// Right-click on a file
|
|
64
|
+
await ai.rightClick('test.js in the file explorer');
|
|
65
|
+
|
|
66
|
+
// Click rename option
|
|
67
|
+
await ai.click('Rename');
|
|
68
|
+
|
|
69
|
+
// Type new name
|
|
70
|
+
await ai.type('test.spec.js');
|
|
71
|
+
await ai.pressKeys('Enter');
|
|
72
|
+
|
|
73
|
+
// Verify rename
|
|
74
|
+
const renamedFile = await ai.find('test.spec.js in the file explorer');
|
|
75
|
+
expect(renamedFile).toBeTruthy();
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Browser Context Menu
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
import { test } from 'vitest';
|
|
83
|
+
import { chrome } from '@testdriver/sdk';
|
|
84
|
+
|
|
85
|
+
test('opens link in new tab', async () => {
|
|
86
|
+
const { ai } = await chrome('https://example.com');
|
|
87
|
+
|
|
88
|
+
// Right-click on a link
|
|
89
|
+
await ai.rightClick('Documentation link');
|
|
90
|
+
|
|
91
|
+
// Select "Open in new tab"
|
|
92
|
+
await ai.click('Open link in new tab');
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Custom Context Menu in Web App
|
|
97
|
+
|
|
98
|
+
```javascript
|
|
99
|
+
test('uses custom context menu', async () => {
|
|
100
|
+
const { ai } = await chrome('https://app.example.com');
|
|
101
|
+
|
|
102
|
+
// Right-click on custom element
|
|
103
|
+
await ai.rightClick('project item in the list');
|
|
104
|
+
|
|
105
|
+
// Wait for custom menu to appear
|
|
106
|
+
await ai.find('custom context menu');
|
|
107
|
+
|
|
108
|
+
// Click menu option
|
|
109
|
+
await ai.click('Duplicate project');
|
|
110
|
+
|
|
111
|
+
// Verify duplication
|
|
112
|
+
const duplicatedProject = await ai.find('project item (copy)');
|
|
113
|
+
expect(duplicatedProject).toBeTruthy();
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Related Methods
|
|
118
|
+
|
|
119
|
+
- [`click()`](/v7/api/click) - Single click on an element
|
|
120
|
+
- [`doubleClick()`](/v7/api/doubleClick) - Double-click on an element
|
|
121
|
+
- [`mouseDown()`](/v7/api/mouseDown) - Press mouse button without releasing
|
|
122
|
+
- [`mouseUp()`](/v7/api/mouseUp) - Release mouse button
|
|
123
|
+
- [`hover()`](/v7/api/hover) - Move mouse over element without clicking
|