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,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testdriver:screenshot
|
|
3
|
+
description: Capture and save screenshots during test execution
|
|
4
|
+
---
|
|
5
|
+
<!-- Generated from screenshot.mdx. DO NOT EDIT. -->
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Capture a screenshot of the current screen and automatically save it to a local file. Screenshots are organized by test file for easy debugging and review.
|
|
10
|
+
|
|
11
|
+
## Syntax
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
const filePath = await testdriver.screenshot(filename)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
<ParamField path="filename" type="string" optional>
|
|
20
|
+
Custom filename for the screenshot (without .png extension). If not provided, a timestamp-based filename is generated automatically.
|
|
21
|
+
</ParamField>
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`Promise<string>` - The absolute file path where the screenshot was saved
|
|
26
|
+
|
|
27
|
+
## File Organization
|
|
28
|
+
|
|
29
|
+
Screenshots are automatically saved to `.testdriver/screenshots/<test-file-name>/` in your project root:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
.testdriver/
|
|
33
|
+
screenshots/
|
|
34
|
+
login.test/
|
|
35
|
+
screenshot-1737633600000.png
|
|
36
|
+
login-page.png
|
|
37
|
+
checkout.test/
|
|
38
|
+
screenshot-1737633700000.png
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
<Note>
|
|
42
|
+
The screenshot folder for each test file is automatically cleared when the test starts. This ensures you only see screenshots from the most recent test run.
|
|
43
|
+
</Note>
|
|
44
|
+
|
|
45
|
+
## Examples
|
|
46
|
+
|
|
47
|
+
### Basic Screenshot
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
// Capture a screenshot with auto-generated filename
|
|
51
|
+
const screenshotPath = await testdriver.screenshot();
|
|
52
|
+
console.log('Screenshot saved to:', screenshotPath);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Custom Filename
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
// Save with a descriptive filename
|
|
59
|
+
await testdriver.screenshot("login-page");
|
|
60
|
+
// Saves to: .testdriver/screenshots/<test>/login-page.png
|
|
61
|
+
|
|
62
|
+
await testdriver.screenshot("after-click");
|
|
63
|
+
// Saves to: .testdriver/screenshots/<test>/after-click.png
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Debugging with Screenshots
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
import { describe, expect, it } from "vitest";
|
|
70
|
+
import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
|
|
71
|
+
|
|
72
|
+
describe("Login Flow", () => {
|
|
73
|
+
it("should log in successfully", async (context) => {
|
|
74
|
+
const testdriver = TestDriver(context);
|
|
75
|
+
|
|
76
|
+
await testdriver.provision.chrome({
|
|
77
|
+
url: 'https://myapp.com/login',
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Capture initial state
|
|
81
|
+
await testdriver.screenshot();
|
|
82
|
+
|
|
83
|
+
// Fill in login form
|
|
84
|
+
const emailInput = await testdriver.find("email input");
|
|
85
|
+
await emailInput.click();
|
|
86
|
+
await testdriver.type("user@example.com");
|
|
87
|
+
|
|
88
|
+
// Capture state after typing
|
|
89
|
+
await testdriver.screenshot();
|
|
90
|
+
|
|
91
|
+
const passwordInput = await testdriver.find("password input");
|
|
92
|
+
await passwordInput.click();
|
|
93
|
+
await testdriver.type("password123");
|
|
94
|
+
|
|
95
|
+
// Capture before clicking login
|
|
96
|
+
await testdriver.screenshot();
|
|
97
|
+
|
|
98
|
+
const loginButton = await testdriver.find("Login button");
|
|
99
|
+
await loginButton.click();
|
|
100
|
+
|
|
101
|
+
// Capture after login attempt
|
|
102
|
+
await testdriver.screenshot();
|
|
103
|
+
|
|
104
|
+
const result = await testdriver.assert("dashboard is visible");
|
|
105
|
+
expect(result).toBeTruthy();
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Best Practices
|
|
111
|
+
|
|
112
|
+
<AccordionGroup>
|
|
113
|
+
<Accordion title="Use screenshots for debugging flaky tests">
|
|
114
|
+
When a test fails intermittently, add screenshots at key steps to capture the actual screen state. This helps identify timing issues or unexpected UI states.
|
|
115
|
+
</Accordion>
|
|
116
|
+
|
|
117
|
+
<Accordion title="Capture before assertions">
|
|
118
|
+
Take a screenshot before making assertions. If the assertion fails, you'll have a visual record of what the screen looked like.
|
|
119
|
+
|
|
120
|
+
```javascript
|
|
121
|
+
await testdriver.screenshot();
|
|
122
|
+
const result = await testdriver.assert("checkout button is visible");
|
|
123
|
+
```
|
|
124
|
+
</Accordion>
|
|
125
|
+
|
|
126
|
+
<Accordion title="Add to .gitignore">
|
|
127
|
+
Add `.testdriver/screenshots/` to your `.gitignore` to avoid committing screenshots to version control:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
# .gitignore
|
|
131
|
+
.testdriver/screenshots/
|
|
132
|
+
```
|
|
133
|
+
</Accordion>
|
|
134
|
+
</AccordionGroup>
|
|
135
|
+
|
|
136
|
+
## Viewing Saved Screenshots
|
|
137
|
+
|
|
138
|
+
After saving screenshots during test execution, you can view them using TestDriver MCP commands. This is especially useful for debugging failed tests or verifying test behavior.
|
|
139
|
+
|
|
140
|
+
### MCP Commands for Screenshot Viewing
|
|
141
|
+
|
|
142
|
+
**List all saved screenshots:**
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
list_local_screenshots()
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**View a specific screenshot:**
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
view_local_screenshot({ path: "/full/path/to/screenshot.png" })
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
These commands allow you to:
|
|
155
|
+
- View screenshots from failed tests to understand what went wrong
|
|
156
|
+
- Review test execution flow by examining screenshots in chronological order
|
|
157
|
+
- Compare screenshots across test runs to identify flaky behavior
|
|
158
|
+
|
|
159
|
+
<Note>
|
|
160
|
+
For detailed workflows and examples of using these MCP commands for debugging, see the [Debugging with Screenshots](/v7/debugging-with-screenshots) guide.
|
|
161
|
+
</Note>
|
|
162
|
+
|
|
163
|
+
## Related
|
|
164
|
+
|
|
165
|
+
- [Debugging with Screenshots](/v7/debugging-with-screenshots) - View and analyze saved screenshots using MCP
|
|
166
|
+
- [assert()](/v7/assert) - Make AI-powered assertions
|
|
167
|
+
- [find()](/v7/find) - Locate elements on screen
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testdriver:scroll
|
|
3
|
+
description: Scroll pages and elements
|
|
4
|
+
---
|
|
5
|
+
<!-- Generated from scroll.mdx. DO NOT EDIT. -->
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Scroll the page or active element in any direction using mouse wheel or keyboard.
|
|
10
|
+
|
|
11
|
+
## Syntax
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
await testdriver.scroll(direction, amount, method)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
<ParamField path="direction" type="string" default="down">
|
|
20
|
+
Direction to scroll: `'up'`, `'down'`, `'left'`, `'right'`
|
|
21
|
+
</ParamField>
|
|
22
|
+
|
|
23
|
+
<ParamField path="amount" type="number" default="300">
|
|
24
|
+
Amount to scroll in pixels
|
|
25
|
+
</ParamField>
|
|
26
|
+
|
|
27
|
+
<ParamField path="method" type="string" default="mouse">
|
|
28
|
+
Scroll method: `'mouse'` or `'keyboard'`
|
|
29
|
+
</ParamField>
|
|
30
|
+
|
|
31
|
+
## Returns
|
|
32
|
+
|
|
33
|
+
`Promise<void>`
|
|
34
|
+
|
|
35
|
+
## Examples
|
|
36
|
+
|
|
37
|
+
### Basic Scrolling
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
// Scroll down (default)
|
|
41
|
+
await testdriver.scroll();
|
|
42
|
+
|
|
43
|
+
// Scroll down 500 pixels
|
|
44
|
+
await testdriver.scroll('down', 500);
|
|
45
|
+
|
|
46
|
+
// Scroll up
|
|
47
|
+
await testdriver.scroll('up');
|
|
48
|
+
|
|
49
|
+
// Scroll up 200 pixels
|
|
50
|
+
await testdriver.scroll('up', 200);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Horizontal Scrolling
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
// Scroll right
|
|
57
|
+
await testdriver.scroll('right', 300);
|
|
58
|
+
|
|
59
|
+
// Scroll left
|
|
60
|
+
await testdriver.scroll('left', 300);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Scroll Methods
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
// Mouse wheel scroll (smooth, pixel-precise)
|
|
67
|
+
await testdriver.scroll('down', 300, 'mouse');
|
|
68
|
+
|
|
69
|
+
// Keyboard scroll (uses Page Down/Up, more compatible)
|
|
70
|
+
await testdriver.scroll('down', 300, 'keyboard');
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Scroll Until Found
|
|
74
|
+
|
|
75
|
+
### scrollUntilText()
|
|
76
|
+
|
|
77
|
+
Scroll until specific text appears on screen.
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
await testdriver.scrollUntilText(text, direction, maxDistance, textMatchMethod, method, invert)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Parameters:**
|
|
84
|
+
- `text` (string) - Text to find
|
|
85
|
+
- `direction` (string) - Scroll direction (default: `'down'`)
|
|
86
|
+
- `maxDistance` (number) - Max pixels to scroll (default: 10000)
|
|
87
|
+
- `textMatchMethod` (string) - `'turbo'` or `'ai'` (default: `'turbo'`)
|
|
88
|
+
- `method` (string) - `'keyboard'` or `'mouse'` (default: `'keyboard'`)
|
|
89
|
+
- `invert` (boolean) - Scroll until text disappears (default: false)
|
|
90
|
+
|
|
91
|
+
**Examples:**
|
|
92
|
+
```javascript
|
|
93
|
+
// Scroll down until "Contact Us" appears
|
|
94
|
+
await testdriver.scrollUntilText('Contact Us');
|
|
95
|
+
|
|
96
|
+
// Scroll up to find text
|
|
97
|
+
await testdriver.scrollUntilText('Header', 'up');
|
|
98
|
+
|
|
99
|
+
// Scroll until text disappears
|
|
100
|
+
await testdriver.scrollUntilText('Loading...', 'down', 5000, 'turbo', 'keyboard', true);
|
|
101
|
+
|
|
102
|
+
// Use AI matching for fuzzy text
|
|
103
|
+
await testdriver.scrollUntilText('footer content', 'down', 10000, 'ai');
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### scrollUntilImage()
|
|
107
|
+
|
|
108
|
+
Scroll until a visual element appears.
|
|
109
|
+
|
|
110
|
+
```javascript
|
|
111
|
+
await testdriver.scrollUntilImage(description, direction, maxDistance, method, path, invert)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Parameters:**
|
|
115
|
+
- `description` (string) - Description of the image/element
|
|
116
|
+
- `direction` (string) - Scroll direction (default: `'down'`)
|
|
117
|
+
- `maxDistance` (number) - Max pixels to scroll (default: 10000)
|
|
118
|
+
- `method` (string) - `'keyboard'` or `'mouse'` (default: `'keyboard'`)
|
|
119
|
+
- `path` (string | null) - Path to image template (optional)
|
|
120
|
+
- `invert` (boolean) - Scroll until image disappears (default: false)
|
|
121
|
+
|
|
122
|
+
**Examples:**
|
|
123
|
+
```javascript
|
|
124
|
+
// Scroll until visual element appears
|
|
125
|
+
await testdriver.scrollUntilImage('red subscribe button');
|
|
126
|
+
|
|
127
|
+
// Scroll using image template
|
|
128
|
+
await testdriver.scrollUntilImage('', 'down', 10000, 'keyboard', './footer-logo.png');
|
|
129
|
+
|
|
130
|
+
// Scroll until image disappears
|
|
131
|
+
await testdriver.scrollUntilImage('loading spinner', 'down', 5000, 'keyboard', null, true);
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Best Practices
|
|
135
|
+
|
|
136
|
+
<Check>
|
|
137
|
+
**Choose the right scroll method**
|
|
138
|
+
|
|
139
|
+
```javascript
|
|
140
|
+
// For web pages, mouse scroll is usually smoother
|
|
141
|
+
await testdriver.scroll('down', 300, 'mouse');
|
|
142
|
+
|
|
143
|
+
// For desktop apps or when mouse doesn't work
|
|
144
|
+
await testdriver.scroll('down', 300, 'keyboard');
|
|
145
|
+
```
|
|
146
|
+
</Check>
|
|
147
|
+
|
|
148
|
+
<Check>
|
|
149
|
+
**Use scrollUntil for dynamic content**
|
|
150
|
+
|
|
151
|
+
```javascript
|
|
152
|
+
// Instead of guessing scroll amount
|
|
153
|
+
await testdriver.scrollUntilText('Load More button');
|
|
154
|
+
|
|
155
|
+
const loadMoreBtn = await testdriver.find('Load More button');
|
|
156
|
+
await loadMoreBtn.click();
|
|
157
|
+
```
|
|
158
|
+
</Check>
|
|
159
|
+
|
|
160
|
+
<Check>
|
|
161
|
+
**Set reasonable max distance**
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
// Avoid infinite scrolling
|
|
165
|
+
await testdriver.scrollUntilText('Footer', 'down', 5000); // Max 5000px
|
|
166
|
+
```
|
|
167
|
+
</Check>
|
|
168
|
+
|
|
169
|
+
<Warning>
|
|
170
|
+
**Keyboard scroll uses Page Down/Up**
|
|
171
|
+
|
|
172
|
+
Keyboard scrolling typically moves by one "page" at a time, which may be more than the specified pixel amount. It's more compatible but less precise than mouse scrolling.
|
|
173
|
+
</Warning>
|
|
174
|
+
|
|
175
|
+
## Use Cases
|
|
176
|
+
|
|
177
|
+
<AccordionGroup>
|
|
178
|
+
<Accordion title="Navigate to Footer">
|
|
179
|
+
```javascript
|
|
180
|
+
// Scroll to bottom of page
|
|
181
|
+
await testdriver.scrollUntilText('Contact Us');
|
|
182
|
+
|
|
183
|
+
const contactLink = await testdriver.find('Contact Us link');
|
|
184
|
+
await contactLink.click();
|
|
185
|
+
```
|
|
186
|
+
</Accordion>
|
|
187
|
+
|
|
188
|
+
<Accordion title="Load More Results">
|
|
189
|
+
```javascript
|
|
190
|
+
// Scroll to load more button
|
|
191
|
+
await testdriver.scrollUntilText('Load More');
|
|
192
|
+
|
|
193
|
+
const loadBtn = await testdriver.find('Load More button');
|
|
194
|
+
await loadBtn.click();
|
|
195
|
+
|
|
196
|
+
await new Promise(r => setTimeout(r, 2000));
|
|
197
|
+
```
|
|
198
|
+
</Accordion>
|
|
199
|
+
|
|
200
|
+
<Accordion title="Find Element in Long List">
|
|
201
|
+
```javascript
|
|
202
|
+
// Scroll through list to find item
|
|
203
|
+
await testdriver.scrollUntilText('Product #42');
|
|
204
|
+
|
|
205
|
+
const product = await testdriver.find('Product #42');
|
|
206
|
+
await product.click();
|
|
207
|
+
```
|
|
208
|
+
</Accordion>
|
|
209
|
+
|
|
210
|
+
<Accordion title="Infinite Scroll">
|
|
211
|
+
```javascript
|
|
212
|
+
// Scroll multiple times for infinite scroll
|
|
213
|
+
for (let i = 0; i < 5; i++) {
|
|
214
|
+
await testdriver.scroll('down', 500);
|
|
215
|
+
await new Promise(r => setTimeout(r, 1000)); // Wait for load
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
</Accordion>
|
|
219
|
+
|
|
220
|
+
<Accordion title="Horizontal Gallery">
|
|
221
|
+
```javascript
|
|
222
|
+
// Navigate horizontal carousel
|
|
223
|
+
await testdriver.scroll('right', 300);
|
|
224
|
+
await new Promise(r => setTimeout(r, 500));
|
|
225
|
+
|
|
226
|
+
const nextImage = await testdriver.find('next image in carousel');
|
|
227
|
+
await nextImage.click();
|
|
228
|
+
```
|
|
229
|
+
</Accordion>
|
|
230
|
+
</AccordionGroup>
|
|
231
|
+
|
|
232
|
+
## Complete Example
|
|
233
|
+
|
|
234
|
+
```javascript
|
|
235
|
+
import { beforeAll, afterAll, describe, it } from 'vitest';
|
|
236
|
+
import TestDriver from 'testdriverai';
|
|
237
|
+
|
|
238
|
+
describe('Scrolling', () => {
|
|
239
|
+
let testdriver;
|
|
240
|
+
|
|
241
|
+
beforeAll(async () => {
|
|
242
|
+
client = new TestDriver(process.env.TD_API_KEY);
|
|
243
|
+
await testdriver.auth();
|
|
244
|
+
await testdriver.connect();
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
afterAll(async () => {
|
|
248
|
+
await testdriver.disconnect();
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it('should scroll to find elements', async () => {
|
|
252
|
+
await testdriver.focusApplication('Google Chrome');
|
|
253
|
+
|
|
254
|
+
// Scroll to footer
|
|
255
|
+
await testdriver.scrollUntilText('Contact Information');
|
|
256
|
+
|
|
257
|
+
// Click footer link
|
|
258
|
+
const privacyLink = await testdriver.find('Privacy Policy link');
|
|
259
|
+
await privacyLink.click();
|
|
260
|
+
|
|
261
|
+
await testdriver.assert('privacy policy page is displayed');
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it('should handle infinite scroll', async () => {
|
|
265
|
+
await testdriver.focusApplication('Google Chrome');
|
|
266
|
+
|
|
267
|
+
// Scroll multiple times to load content
|
|
268
|
+
for (let i = 0; i < 3; i++) {
|
|
269
|
+
await testdriver.scroll('down', 500);
|
|
270
|
+
await new Promise(r => setTimeout(r, 1500)); // Wait for load
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Verify content loaded
|
|
274
|
+
await testdriver.assert('more than 10 items are visible');
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('should scroll until loading completes', async () => {
|
|
278
|
+
// Scroll until loading spinner disappears
|
|
279
|
+
await testdriver.scrollUntilImage(
|
|
280
|
+
'loading spinner',
|
|
281
|
+
'down',
|
|
282
|
+
5000,
|
|
283
|
+
'keyboard',
|
|
284
|
+
null,
|
|
285
|
+
true // invert - wait for it to disappear
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
// Now interact with loaded content
|
|
289
|
+
const firstResult = await testdriver.find('first search result');
|
|
290
|
+
await firstResult.click();
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Related Methods
|
|
296
|
+
|
|
297
|
+
- [`find()`](/v7/find) - Locate elements after scrolling
|
|
298
|
+
- [`pressKeys()`](/v7/press-keys) - Use Page Down/Up keys
|
|
299
|
+
- [`wait()`](/v7/wait) - Wait after scrolling
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testdriver:secrets
|
|
3
|
+
description: Securely manage passwords and sensitive data in your tests
|
|
4
|
+
---
|
|
5
|
+
<!-- Generated from secrets.mdx. DO NOT EDIT. -->
|
|
6
|
+
|
|
7
|
+
Protect sensitive information like passwords, API keys, and tokens in your TestDriver tests.
|
|
8
|
+
|
|
9
|
+
## Typing Secrets Securely
|
|
10
|
+
|
|
11
|
+
When typing sensitive information like passwords, use the `secret: true` option to prevent the value from being logged or stored:
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
import { test } from 'vitest';
|
|
15
|
+
import { chrome } from 'testdriverai/presets';
|
|
16
|
+
|
|
17
|
+
test('login with secure password', async (context) => {
|
|
18
|
+
const { testdriver } = await chrome(context, {
|
|
19
|
+
url: 'https://myapp.com/login'
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
await testdriver.find('email input').click();
|
|
23
|
+
await testdriver.type(process.env.TD_USERNAME);
|
|
24
|
+
|
|
25
|
+
await testdriver.find('password input').click();
|
|
26
|
+
// Password is masked in logs and recordings
|
|
27
|
+
await testdriver.type(process.env.TD_PASSWORD, { secret: true });
|
|
28
|
+
|
|
29
|
+
await testdriver.find('login button').click();
|
|
30
|
+
await testdriver.assert('dashboard is visible');
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
<Note>
|
|
35
|
+
When `secret: true` is set, the typed text appears as `****` in all logs, recordings, and dashcam output.
|
|
36
|
+
</Note>
|
|
37
|
+
|
|
38
|
+
## Storing Secrets in GitHub
|
|
39
|
+
|
|
40
|
+
Store sensitive credentials as GitHub repository secrets so they're never exposed in your code:
|
|
41
|
+
|
|
42
|
+
<Steps>
|
|
43
|
+
<Step title="Navigate to Repository Settings">
|
|
44
|
+
Go to your GitHub repository → **Settings** → **Secrets and variables** → **Actions**
|
|
45
|
+
</Step>
|
|
46
|
+
<Step title="Add Repository Secrets">
|
|
47
|
+
Click **New repository secret** and add your secrets:
|
|
48
|
+
- `TD_API_KEY` - Your TestDriver API key
|
|
49
|
+
- `TD_USERNAME` - Test account username
|
|
50
|
+
- `TD_PASSWORD` - Test account password
|
|
51
|
+
</Step>
|
|
52
|
+
<Step title="Use in GitHub Actions">
|
|
53
|
+
Reference secrets in your workflow file:
|
|
54
|
+
```yaml .github/workflows/test.yml
|
|
55
|
+
- name: Run TestDriver tests
|
|
56
|
+
env:
|
|
57
|
+
TD_API_KEY: ${{ secrets.TD_API_KEY }}
|
|
58
|
+
TD_USERNAME: ${{ secrets.TD_USERNAME }}
|
|
59
|
+
TD_PASSWORD: ${{ secrets.TD_PASSWORD }}
|
|
60
|
+
run: vitest run
|
|
61
|
+
```
|
|
62
|
+
</Step>
|
|
63
|
+
</Steps>
|
|
64
|
+
|
|
65
|
+
## Local Development
|
|
66
|
+
|
|
67
|
+
For local development, store secrets in a `.env` file:
|
|
68
|
+
|
|
69
|
+
```bash .env
|
|
70
|
+
TD_API_KEY=your_api_key_here
|
|
71
|
+
TD_USERNAME=testuser@example.com
|
|
72
|
+
TD_PASSWORD=your_secure_password
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
<Warning>
|
|
76
|
+
Never commit `.env` files to version control. Add `.env` to your `.gitignore` file.
|
|
77
|
+
</Warning>
|
|
78
|
+
|
|
79
|
+
## Complete Example
|
|
80
|
+
|
|
81
|
+
Here's a full login test with proper secrets handling:
|
|
82
|
+
|
|
83
|
+
```javascript tests/login.test.js
|
|
84
|
+
import { test, expect } from 'vitest';
|
|
85
|
+
import { chrome } from 'testdriverai/presets';
|
|
86
|
+
|
|
87
|
+
test('secure login flow', async (context) => {
|
|
88
|
+
const { testdriver } = await chrome(context, {
|
|
89
|
+
url: process.env.TD_WEBSITE || 'https://staging.myapp.com'
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Enter username (not sensitive)
|
|
93
|
+
await testdriver.find('email input').click();
|
|
94
|
+
await testdriver.type(process.env.TD_USERNAME);
|
|
95
|
+
|
|
96
|
+
// Enter password securely
|
|
97
|
+
await testdriver.find('password input').click();
|
|
98
|
+
await testdriver.type(process.env.TD_PASSWORD, { secret: true });
|
|
99
|
+
|
|
100
|
+
// Submit login
|
|
101
|
+
await testdriver.find('login button').click();
|
|
102
|
+
|
|
103
|
+
// Verify successful login
|
|
104
|
+
const loggedIn = await testdriver.assert('user is logged in');
|
|
105
|
+
expect(loggedIn).toBeTruthy();
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
<Card title="Secrets Best Practices" icon="shield-check">
|
|
110
|
+
- **Always use `secret: true`** when typing passwords, tokens, or sensitive data
|
|
111
|
+
- **Use environment variables** to keep secrets out of code
|
|
112
|
+
- **Store secrets in your CI provider** (GitHub Actions, GitLab CI, etc.)
|
|
113
|
+
- **Never commit secrets** to version control
|
|
114
|
+
- **Rotate secrets regularly** to maintain security
|
|
115
|
+
</Card>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testdriver:self-hosted
|
|
3
|
+
description: Unlimited test execution, complete privacy, and the ability to customize everything — all for a predictable flat license fee.
|
|
4
|
+
---
|
|
5
|
+
<!-- Generated from self-hosted.mdx. DO NOT EDIT. -->
|
|
6
|
+
|
|
7
|
+
Self-hosted pricing is based on **parallel test capacity**: the number of tests you can run simultaneously on **your infrastructure**.
|
|
8
|
+
|
|
9
|
+
With self-hosting, you get:.
|
|
10
|
+
|
|
11
|
+
- **Flat license fee** per parallel test slot
|
|
12
|
+
- **Unlimited test execution** — run as many tests as you want
|
|
13
|
+
- **No device-second metering** — predictable monthly costs
|
|
14
|
+
- **Use your own AI keys** — control data usage with your own OpenAI, Anthropic, or other AI provider keys
|
|
15
|
+
- **Custom hardware & software** — choose instance types, resolution, install specific software, and configure networking as needed
|
|
16
|
+
- **Debug & Customize** — RDP into test machines, install custom software, modify the AMI, and debug issues directly. No black boxes.
|
|
17
|
+
|
|
18
|
+
## Get Started
|
|
19
|
+
|
|
20
|
+
Ready to self-host? Follow our comprehensive AWS setup guide:
|
|
21
|
+
|
|
22
|
+
<Card
|
|
23
|
+
title="AWS Setup Guide"
|
|
24
|
+
icon="aws"
|
|
25
|
+
href="/v7/aws-setup"
|
|
26
|
+
>
|
|
27
|
+
Step-by-step instructions for deploying TestDriver on your AWS infrastructure using CloudFormation.
|
|
28
|
+
</Card>
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Who Should Self-Host?
|
|
32
|
+
|
|
33
|
+
Self-hosting is ideal for teams that:
|
|
34
|
+
|
|
35
|
+
- **Run high test volumes** — Flat pricing becomes more economical at scale
|
|
36
|
+
- **Want infrastructure control** — Custom hardware, specific software dependencies, or network configurations
|
|
37
|
+
- **Prefer predictable costs** — Budget with confidence using flat monthly fees
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## How It Works
|
|
41
|
+
|
|
42
|
+
With self-hosting, you run test sandboxes on your own AWS infrastructure. TestDriver still provides:
|
|
43
|
+
|
|
44
|
+
- **Dashboard** — View test results, analytics, and reports at [console.testdriver.ai](https://console.testdriver.ai)
|
|
45
|
+
- **API** — Orchestration and AI-powered test execution
|
|
46
|
+
- **License Management** — Your parallel test capacity
|
|
47
|
+
|
|
48
|
+
You provide:
|
|
49
|
+
|
|
50
|
+
- **AWS Infrastructure** — EC2 instances running in your account
|
|
51
|
+
- **AI API Keys** — Use your own OpenAI, Anthropic, or other AI provider keys
|
|
52
|
+
- **Custom Configuration** — Hardware specs, networking, installed software
|
|
53
|
+
|
|
54
|
+
## Comparison vs Cloud
|
|
55
|
+
|
|
56
|
+
| Feature | Cloud | Self-Hosted |
|
|
57
|
+
|---------|-------|-------------|
|
|
58
|
+
| **Setup Time** | Minutes | Hours |
|
|
59
|
+
| **Pricing Model** | Device-seconds | Flat license fee |
|
|
60
|
+
| **Infrastructure Management** | TestDriver | You |
|
|
61
|
+
| **Device Location** | TestDriver cloud | Your AWS account |
|
|
62
|
+
| **AI API Keys** | TestDriver's | Your own |
|
|
63
|
+
| **Custom Software** | Limited | Full control |
|
|
64
|
+
| **Hardware Selection** | Standard | Your choice |
|
|
65
|
+
| **Debugging Access** | Replays only | Full RDP access |
|