@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
@@ -1,161 +1,84 @@
1
1
  ---
2
- title: "mouseDown"
3
- description: "Press the mouse button without releasing it"
2
+ title: "mouseDown()"
3
+ sidebarTitle: "mouseDown"
4
+ description: "Press and hold the left mouse button on an element, to start a drag."
4
5
  icon: "arrow-pointer"
5
6
  ---
6
7
 
7
- ## Overview
8
-
9
- The `mouseDown()` method pushes the mouse button at the location of an element. It does not release the button. Use this for drag operations, custom gestures, or when you need precise control of the mouse events. You can call it on an [`Element`](/core-concepts/elements) instance. Or you can use it with a selector.
10
-
11
- ## Syntax
8
+ Press the left mouse button on an element and keep it held down. Use it with [`hover()`](/hover) and [`mouseUp()`](/mouse-up) to drag and drop:
12
9
 
13
10
  ```javascript
14
- // Mouse down on an element
15
- await element.mouseDown();
16
-
17
- // Mouse down using a selector
18
- await ai.mouseDown('selector');
11
+ await testdriver.find('Task card titled "Write docs"').mouseDown();
12
+ await testdriver.find('Done column').hover();
13
+ await testdriver.find('Done column').mouseUp();
19
14
  ```
20
15
 
21
- ## Parameters
16
+ ## element.mouseDown()
22
17
 
23
- When called on an `Element`, no parameters are required.
18
+ Moves the mouse to the point where [`find()`](/find) located the element, then presses the left button. The button stays down until you call `mouseUp()`. It's the same as `element.click('mouseDown')`.
24
19
 
25
- When called directly on the AI client:
20
+ ```typescript
21
+ element.mouseDown(): Promise<void>
22
+ ```
26
23
 
27
- | Parameter | Type | Description |
28
- |-----------|------|-------------|
29
- | `selector` | `string` | The selector describing the element where the mouse button should be pressed |
24
+ It takes no parameters.
30
25
 
31
- ## Returns
26
+ ### Errors
32
27
 
33
- It returns a `Promise<void>`. The promise resolves when TestDriver pushes the mouse button.
28
+ Throws an `ElementNotFoundError` if `find()` didn't locate the element. See [click()](/click#errors) for how to check `found()` first.
34
29
 
35
- ## Examples
30
+ ## Press at coordinates
36
31
 
37
- ### Basic Drag Operation
32
+ The client has no `mouseDown()` method. To press the button at a point on the screen, pass `action: 'mouseDown'` to [`testdriver.click()`](/click#testdriver-click-options):
38
33
 
39
34
  ```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();
35
+ await testdriver.click({ x: 200, y: 300, action: 'mouseDown' });
36
+ await testdriver.click({ x: 600, y: 300, action: 'mouseUp' });
50
37
  ```
51
38
 
52
- ### Drag and Drop with Direct Selectors
39
+ Prefer the element methods, which keep working when the layout or screen size changes.
53
40
 
54
- ```javascript
55
- await ai.mouseDown('draggable card');
56
- await ai.hover('drop zone');
57
- await ai.mouseUp();
58
- ```
41
+ ## Examples
59
42
 
60
- ### Selecting Multiple Items
43
+ ### Reorder a list
61
44
 
62
45
  ```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
- });
46
+ await testdriver.find('drag handle on the first task in the list').mouseDown();
47
+ await testdriver.find('the third task in the list').mouseUp();
82
48
  ```
83
49
 
84
- ### Custom Drawing Application
50
+ ### Draw on a canvas
85
51
 
86
52
  ```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
- });
53
+ await testdriver.find('top-left corner of the drawing canvas').mouseDown();
54
+ await testdriver.find('center of the drawing canvas').hover();
55
+ await testdriver.find('bottom-right corner of the drawing canvas').mouseUp();
104
56
  ```
105
57
 
106
- ### Long Press Gesture
58
+ ## Complete example
107
59
 
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
- ```
60
+ ```javascript tests/drag-and-drop.test.mjs
61
+ import { describe, expect, it } from 'vitest';
62
+ import { TestDriver } from 'testdriverai/vitest/hooks';
126
63
 
127
- ### Resizing UI Elements
64
+ describe('Drag and drop', () => {
65
+ it('moves a task to the Done column', async (context) => {
66
+ const testdriver = TestDriver(context);
67
+ await testdriver.provision.chrome({ url: 'https://your-app.example.com/board' });
128
68
 
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);
69
+ await testdriver.find('Task card titled "Write docs"').mouseDown();
70
+ await testdriver.find('Done column').hover();
71
+ await testdriver.find('Done column').mouseUp();
72
+
73
+ const result = await testdriver.assert('the "Write docs" card is in the Done column');
74
+ expect(result).toBe(true);
75
+ });
145
76
  });
146
77
  ```
147
78
 
148
- ## Important Notes
149
-
150
- - Always pair `mouseDown()` with [`mouseUp()`](/mouse-up) to complete the gesture
151
- - The mouse button remains pressed until `mouseUp()` is called
152
- - Use [`hover()`](/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
79
+ ## Related
156
80
 
157
- - [`mouseUp()`](/mouse-up) - Release the mouse button
158
- - [`hover()`](/hover) - Move mouse to element
159
- - [`click()`](/click) - Full click (mouseDown + mouseUp)
160
- - [`doubleClick()`](/double-click) - Double-click on element
161
- - [`rightClick()`](/right-click) - Right-click for context menu
81
+ - [mouseUp()](/mouse-up): release the button
82
+ - [hover()](/hover): move the mouse while the button is down
83
+ - [click()](/click): a full press and release
84
+ - [Perform actions](/performing-actions): every kind of action in one guide
package/docs/mouse-up.mdx CHANGED
@@ -1,164 +1,82 @@
1
1
  ---
2
- title: "mouseUp"
3
- description: "Release the mouse button"
2
+ title: "mouseUp()"
3
+ sidebarTitle: "mouseUp"
4
+ description: "Release the left mouse button on an element, to finish a drag."
4
5
  icon: "arrow-pointer"
5
6
  ---
6
7
 
7
- ## Overview
8
-
9
- The `mouseUp()` method releases the mouse button. It completes a drag operation or a custom mouse gesture that you started with [`mouseDown()`](/mouse-down). Call it without parameters to release the button at the present mouse position.
10
-
11
- ## Syntax
8
+ Release the mouse button you pressed with [`mouseDown()`](/mouse-down). Call it on the element where the drag should end:
12
9
 
13
10
  ```javascript
14
- // Release mouse button at current position
15
- await ai.mouseUp();
11
+ await testdriver.find('Task card titled "Write docs"').mouseDown();
12
+ await testdriver.find('Done column').mouseUp();
16
13
  ```
17
14
 
18
- ## Parameters
15
+ ## element.mouseUp()
19
16
 
20
- None. The mouse button is released at the current cursor position.
17
+ Moves the mouse to the point where [`find()`](/find) located the element, then releases the left button. Because the mouse moves before the release, the app sees a drag rather than a jump. It's the same as `element.click('mouseUp')`.
21
18
 
22
- ## Returns
19
+ ```typescript
20
+ element.mouseUp(): Promise<void>
21
+ ```
23
22
 
24
- It returns a `Promise<void>`. The promise resolves when TestDriver releases the mouse button.
23
+ It takes no parameters.
25
24
 
26
- ## Examples
25
+ ### Errors
27
26
 
28
- ### Complete Drag and Drop
27
+ Throws an `ElementNotFoundError` if `find()` didn't locate the element. See [click()](/click#errors) for how to check `found()` first.
29
28
 
30
- ```javascript
31
- // Start dragging
32
- await ai.mouseDown('file to drag');
29
+ ## Release at coordinates
33
30
 
34
- // Move to drop location
35
- await ai.hover('target folder');
31
+ The client has no `mouseUp()` method. To release the button at a point on the screen, pass `action: 'mouseUp'` to [`testdriver.click()`](/click#testdriver-click-options):
36
32
 
37
- // Complete the drop
38
- await ai.mouseUp();
33
+ ```javascript
34
+ await testdriver.click({ x: 600, y: 300, action: 'mouseUp' });
39
35
  ```
40
36
 
41
- ### Selecting Multiple Files
37
+ Prefer `element.mouseUp()`, which keeps working when the layout or screen size changes.
42
38
 
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
- ```
39
+ ## Examples
63
40
 
64
- ### Drawing Application
41
+ ### Drop a file into an upload area
65
42
 
66
43
  ```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
- });
44
+ await testdriver.find('invoice.pdf in the file list').mouseDown();
45
+ await testdriver.find('Drop files here area').hover();
46
+ await testdriver.find('Drop files here area').mouseUp();
83
47
  ```
84
48
 
85
- ### Resizing Window Panels
49
+ ### Resize a panel
86
50
 
87
51
  ```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
- });
52
+ await testdriver.find('divider between the sidebar and the editor').mouseDown();
53
+ await testdriver.find('middle of the editor area').mouseUp();
104
54
  ```
105
55
 
106
- ### Drag to Reorder List Items
56
+ ## Complete example
107
57
 
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
- ```
58
+ ```javascript tests/drag-and-drop.test.mjs
59
+ import { describe, expect, it } from 'vitest';
60
+ import { TestDriver } from 'testdriverai/vitest/hooks';
129
61
 
130
- ### Text Selection with Mouse
62
+ describe('Drag and drop', () => {
63
+ it('moves a task to the Done column', async (context) => {
64
+ const testdriver = TestDriver(context);
65
+ await testdriver.provision.chrome({ url: 'https://your-app.example.com/board' });
131
66
 
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');
67
+ await testdriver.find('Task card titled "Write docs"').mouseDown();
68
+ await testdriver.find('Done column').hover();
69
+ await testdriver.find('Done column').mouseUp();
70
+
71
+ const result = await testdriver.assert('the "Write docs" card is in the Done column');
72
+ expect(result).toBe(true);
73
+ });
148
74
  });
149
75
  ```
150
76
 
151
- ## Important Notes
152
-
153
- - `mouseUp()` must be preceded by [`mouseDown()`](/mouse-down) 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()`](/click) instead of mouseDown/mouseUp pair
157
-
158
- ## Related Methods
77
+ ## Related
159
78
 
160
- - [`mouseDown()`](/mouse-down) - Press mouse button without releasing
161
- - [`hover()`](/hover) - Move mouse to element
162
- - [`click()`](/click) - Complete click (mouseDown + mouseUp)
163
- - [`doubleClick()`](/double-click) - Double-click on element
164
- - [`rightClick()`](/right-click) - Right-click for context menu
79
+ - [mouseDown()](/mouse-down): press the button
80
+ - [hover()](/hover): move the mouse while the button is down
81
+ - [click()](/click): a full press and release
82
+ - [Perform actions](/performing-actions): every kind of action in one guide