@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.
- package/docs/_data/examples-manifest.json +16 -16
- package/docs/_scripts/generate-examples.js +38 -45
- package/docs/agent.mdx +174 -93
- package/docs/assert.mdx +73 -269
- package/docs/aws-setup.mdx +196 -314
- package/docs/bring-your-own-machine.mdx +139 -206
- package/docs/cache.mdx +144 -151
- package/docs/caching.mdx +99 -89
- package/docs/captcha.mdx +126 -111
- package/docs/ci-cd.mdx +154 -543
- package/docs/click.mdx +74 -229
- package/docs/client.mdx +177 -231
- package/docs/copilot/auto-healing.mdx +86 -370
- package/docs/copilot/running-tests.mdx +121 -930
- package/docs/customizing-devices.mdx +74 -251
- package/docs/dashcam.mdx +72 -405
- package/docs/debugging-with-screenshots.mdx +105 -371
- package/docs/docs.json +75 -18
- package/docs/double-click.mdx +48 -68
- package/docs/errors.mdx +102 -176
- package/docs/events.mdx +170 -327
- package/docs/examples/{hover-text-with-description.mdx → add-to-cart.mdx} +30 -35
- package/docs/examples/assert.mdx +28 -41
- package/docs/examples/click-button.mdx +71 -0
- package/docs/examples/{hover-image.mdx → click-icon.mdx} +32 -28
- package/docs/examples/element-not-found.mdx +27 -26
- package/docs/examples/findall-coffee-icons.mdx +28 -32
- package/docs/examples/installer.mdx +61 -25
- package/docs/examples/launch-vscode-linux.mdx +28 -51
- package/docs/examples/navigate-and-scroll.mdx +82 -0
- package/docs/examples/parse.mdx +24 -28
- package/docs/examples/press-keys.mdx +28 -25
- package/docs/examples/scroll.mdx +25 -27
- package/docs/examples/type.mdx +26 -21
- package/docs/exec.mdx +92 -256
- package/docs/extract.mdx +69 -170
- package/docs/find.mdx +140 -736
- package/docs/focus-application.mdx +69 -246
- package/docs/generating-tests.mdx +103 -137
- package/docs/guide/best-practices-polling.mdx +65 -141
- package/docs/hosted.mdx +80 -144
- package/docs/hover.mdx +62 -235
- package/docs/locating-elements.mdx +74 -369
- package/docs/making-assertions.mdx +116 -74
- package/docs/mcp-setup.mdx +80 -63
- package/docs/mouse-down.mdx +48 -125
- package/docs/mouse-up.mdx +47 -129
- package/docs/options.mdx +75 -48
- package/docs/parse.mdx +95 -184
- package/docs/performing-actions.mdx +104 -94
- package/docs/press-keys.mdx +59 -299
- package/docs/provision.mdx +137 -182
- package/docs/quickstart-claude.mdx +85 -0
- package/docs/quickstart-github.mdx +62 -32
- package/docs/quickstart-manual.mdx +60 -33
- package/docs/quickstart-vscode.mdx +97 -0
- package/docs/quickstart.mdx +25 -9
- package/docs/redraw.mdx +101 -165
- package/docs/reusable-code.mdx +97 -200
- package/docs/right-click.mdx +47 -89
- package/docs/screenshot.mdx +47 -201
- package/docs/screenshots.mdx +87 -137
- package/docs/scroll.mdx +71 -154
- package/docs/secrets.mdx +96 -91
- package/docs/self-hosted.mdx +83 -142
- package/docs/snippets/enterprise.mdx +15 -0
- package/docs/styles.css +68 -0
- package/docs/test-results-json.mdx +167 -204
- package/docs/type.mdx +56 -304
- package/docs/variables.mdx +121 -81
- package/docs/wait.mdx +33 -31
- package/docs/what-is-testdriver.mdx +80 -32
- package/examples/{hover-text-with-description.test.mjs → add-to-cart.test.mjs} +4 -5
- package/examples/assert.test.mjs +3 -20
- package/examples/{hover-text.test.mjs → click-button.test.mjs} +3 -4
- package/examples/{hover-image.test.mjs → click-icon.test.mjs} +5 -6
- package/examples/element-not-found.test.mjs +3 -5
- package/examples/findall-coffee-icons.test.mjs +3 -3
- package/examples/installer.test.mjs +1 -1
- package/examples/launch-vscode-linux.test.mjs +6 -33
- package/examples/{scroll-keyboard.test.mjs → navigate-and-scroll.test.mjs} +4 -5
- package/examples/parse.test.mjs +1 -2
- package/examples/press-keys.test.mjs +4 -4
- package/examples/scroll.test.mjs +3 -6
- package/examples/type.test.mjs +5 -2
- package/lib/provision.js +6 -2
- package/package.json +1 -1
- package/sdk.d.ts +4 -2
- package/sdk.js +1 -1
- package/docs/claude-mcp-plugin.mdx +0 -244
- package/docs/elements.mdx +0 -606
- package/docs/examples/ai.mdx +0 -78
- package/docs/examples/captcha-api.mdx +0 -92
- package/docs/examples/chrome-extension.mdx +0 -156
- package/docs/examples/drag-and-drop.mdx +0 -100
- package/docs/examples/formatted-logging.mdx +0 -74
- package/docs/examples/hover-text.mdx +0 -70
- package/docs/examples/match-image.mdx +0 -97
- package/docs/examples/scroll-keyboard.mdx +0 -80
- package/docs/examples/scroll-until-text.mdx +0 -109
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
2
|
+
title: "Launch VS Code"
|
|
3
3
|
sidebarTitle: "Launch VS Code"
|
|
4
|
-
description: "
|
|
5
|
-
icon: "
|
|
4
|
+
description: "Launch VS Code in a Linux sandbox and check that its window opens."
|
|
5
|
+
icon: "code"
|
|
6
6
|
mode: "wide"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
This test launches VS Code with `provision.vscode()` and waits for its window to appear.
|
|
10
10
|
|
|
11
|
-
Watch
|
|
11
|
+
## Watch it run
|
|
12
12
|
|
|
13
13
|
{/* launch-vscode-linux.test.mjs output */}
|
|
14
14
|
<iframe
|
|
@@ -19,9 +19,9 @@ Watch this test execute in a real sandbox environment:
|
|
|
19
19
|
allow="fullscreen"
|
|
20
20
|
/>
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## The test
|
|
23
23
|
|
|
24
|
-
```javascript title="launch-vscode-linux.test.mjs"
|
|
24
|
+
```javascript title="launch-vscode-linux.test.mjs"
|
|
25
25
|
import { describe, expect, it } from "vitest";
|
|
26
26
|
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
27
27
|
|
|
@@ -31,12 +31,11 @@ describe("Launch VS Code on Linux", () => {
|
|
|
31
31
|
it.skipIf(!isLinux)(
|
|
32
32
|
"should launch VS Code on Debian/Ubuntu",
|
|
33
33
|
async (context) => {
|
|
34
|
-
const testdriver = TestDriver(context
|
|
35
|
-
|
|
36
|
-
// provision.vscode() automatically calls ready() and starts dashcam
|
|
34
|
+
const testdriver = TestDriver(context);
|
|
35
|
+
|
|
37
36
|
await testdriver.provision.vscode();
|
|
38
37
|
|
|
39
|
-
//
|
|
38
|
+
// Poll for up to 60 seconds while VS Code starts
|
|
40
39
|
const vsCodeWindow = await testdriver.find(
|
|
41
40
|
"Visual Studio Code window",
|
|
42
41
|
{ timeout: 60000 }
|
|
@@ -45,53 +44,31 @@ describe("Launch VS Code on Linux", () => {
|
|
|
45
44
|
},
|
|
46
45
|
);
|
|
47
46
|
|
|
48
|
-
// it.skipIf(!isLinux)(
|
|
49
|
-
// "should install and use a VS Code extension",
|
|
50
|
-
// async (context) => {
|
|
51
|
-
// const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP});
|
|
52
|
-
|
|
53
|
-
// // Launch VS Code with the Prettier extension installed
|
|
54
|
-
// await testdriver.provision.vscode({
|
|
55
|
-
// extensions: ["esbenp.prettier-vscode"],
|
|
56
|
-
// });
|
|
57
|
-
|
|
58
|
-
// const vsCodeWindow = await testdriver.find(
|
|
59
|
-
// "Visual Studio Code window",
|
|
60
|
-
// { timeout: 60000 }
|
|
61
|
-
// );
|
|
62
|
-
|
|
63
|
-
// expect(vsCodeWindow.found()).toBeTruthy();
|
|
64
|
-
|
|
65
|
-
// // Open the extensions panel to verify Prettier is installed
|
|
66
|
-
// await testdriver.pressKeys(["ctrl", "shift", "x"]);
|
|
67
|
-
|
|
68
|
-
// // Wait for extensions panel to open
|
|
69
|
-
// await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
70
|
-
|
|
71
|
-
// // Assert that Prettier extension is visible in the installed extensions
|
|
72
|
-
// const prettierVisible = await testdriver.assert(
|
|
73
|
-
// "Prettier extension is visible in the extensions panel or sidebar",
|
|
74
|
-
// );
|
|
75
|
-
// expect(prettierVisible).toBeTruthy();
|
|
76
|
-
// },
|
|
77
|
-
// );
|
|
78
47
|
});
|
|
79
48
|
```
|
|
80
49
|
|
|
81
|
-
##
|
|
50
|
+
## How it works
|
|
51
|
+
|
|
52
|
+
- `provision.vscode()` starts VS Code in the sandbox.
|
|
53
|
+
- `timeout: 60000` makes `find()` keep checking for up to 60 seconds. This gives VS Code time to start.
|
|
54
|
+
- `found()` returns `true` once the window is on screen.
|
|
55
|
+
- `it.skipIf(!isLinux)` skips the test when `TD_OS` is set to `windows`.
|
|
56
|
+
|
|
57
|
+
## Run it
|
|
58
|
+
|
|
59
|
+
The test is in the [TestDriver SDK repository](https://github.com/testdriverai/testdriverai/tree/main/examples). Clone it, install dependencies, and run the file:
|
|
82
60
|
|
|
83
61
|
```bash
|
|
84
|
-
# Clone the TestDriver repository
|
|
85
62
|
git clone https://github.com/testdriverai/testdriverai
|
|
86
|
-
|
|
87
|
-
# Install dependencies
|
|
88
63
|
cd testdriverai
|
|
89
64
|
npm install
|
|
90
|
-
|
|
91
|
-
# Run this specific example
|
|
92
|
-
vitest run examples/launch-vscode-linux.test.mjs
|
|
65
|
+
npx vitest run examples/launch-vscode-linux.test.mjs
|
|
93
66
|
```
|
|
94
67
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
68
|
+
The test reads your API key from `TD_API_KEY`. Create a key at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys). Then set it in your environment or a `.env` file.
|
|
69
|
+
|
|
70
|
+
## Related
|
|
71
|
+
|
|
72
|
+
- [Provision apps](/provision)
|
|
73
|
+
- [find()](/find)
|
|
74
|
+
- [Waiting for elements](/guide/best-practices-polling)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Navigate with the address bar and scroll"
|
|
3
|
+
sidebarTitle: "Address bar and scroll"
|
|
4
|
+
description: "Navigate by typing in Chrome's address bar, then scroll and assert on the result."
|
|
5
|
+
icon: "scroll"
|
|
6
|
+
mode: "wide"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
This test types a URL into Chrome's address bar, scrolls down, and asserts that the heading is out of view.
|
|
10
|
+
|
|
11
|
+
## Watch it run
|
|
12
|
+
|
|
13
|
+
{/* navigate-and-scroll.test.mjs output */}
|
|
14
|
+
<iframe
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6ad6b600022b6043aeec2bf0/replay"
|
|
16
|
+
width="100%"
|
|
17
|
+
height="390"
|
|
18
|
+
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
19
|
+
allow="fullscreen"
|
|
20
|
+
/>
|
|
21
|
+
|
|
22
|
+
## The test
|
|
23
|
+
|
|
24
|
+
```javascript title="navigate-and-scroll.test.mjs"
|
|
25
|
+
import { describe, expect, it } from "vitest";
|
|
26
|
+
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
27
|
+
|
|
28
|
+
describe("Scroll Keyboard Test", () => {
|
|
29
|
+
it("should navigate to webhamster.com and scroll with keyboard", async (context) => {
|
|
30
|
+
const testdriver = TestDriver(context);
|
|
31
|
+
await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });
|
|
32
|
+
|
|
33
|
+
// Navigate to https://www.webhamster.com/ through the address bar
|
|
34
|
+
await testdriver.focusApplication("Google Chrome");
|
|
35
|
+
const urlBar = await testdriver.find(
|
|
36
|
+
"the URL in the omnibox", {zoom: true}
|
|
37
|
+
);
|
|
38
|
+
await urlBar.click();
|
|
39
|
+
await testdriver.pressKeys(["ctrl", "a"]);
|
|
40
|
+
await testdriver.type("https://www.webhamster.com/");
|
|
41
|
+
await testdriver.pressKeys(["enter"]);
|
|
42
|
+
|
|
43
|
+
// Click the page so it has focus, then scroll down
|
|
44
|
+
const heading = await testdriver.find(
|
|
45
|
+
"The Hamster Dance, large heading at top of page",
|
|
46
|
+
);
|
|
47
|
+
await heading.click();
|
|
48
|
+
await testdriver.scroll("down", { amount: 1000 });
|
|
49
|
+
|
|
50
|
+
// Assert the page is scrolled down
|
|
51
|
+
const result = await testdriver.assert("The text 'The Hamster Dance' is not visible on the webpage content. It's ok if it's visible in the tab title.");
|
|
52
|
+
|
|
53
|
+
expect(result).toBeTruthy();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## How it works
|
|
59
|
+
|
|
60
|
+
- `find()` with `zoom: true` locates the element in two passes for extra precision. This helps with small targets like the address bar.
|
|
61
|
+
- `pressKeys(['ctrl', 'a'])` selects the current URL so `type()` replaces it.
|
|
62
|
+
- The test clicks the page before scrolling so the page, not the address bar, gets the scroll.
|
|
63
|
+
- `scroll('down', { amount: 1000 })` scrolls down with the mouse wheel.
|
|
64
|
+
|
|
65
|
+
## Run it
|
|
66
|
+
|
|
67
|
+
The test is in the [TestDriver SDK repository](https://github.com/testdriverai/testdriverai/tree/main/examples). Clone it, install dependencies, and run the file:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
git clone https://github.com/testdriverai/testdriverai
|
|
71
|
+
cd testdriverai
|
|
72
|
+
npm install
|
|
73
|
+
npx vitest run examples/navigate-and-scroll.test.mjs
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The test reads your API key from `TD_API_KEY`. Create a key at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys). Then set it in your environment or a `.env` file.
|
|
77
|
+
|
|
78
|
+
## Related
|
|
79
|
+
|
|
80
|
+
- [scroll()](/scroll)
|
|
81
|
+
- [find()](/find)
|
|
82
|
+
- [focusApplication()](/focus-application)
|
package/docs/examples/parse.mdx
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
2
|
+
title: "List the elements on screen"
|
|
3
3
|
sidebarTitle: "Parse"
|
|
4
|
-
description: "
|
|
5
|
-
icon: "
|
|
4
|
+
description: "Open a website and use parse() to list the UI elements on screen."
|
|
5
|
+
icon: "table-list"
|
|
6
6
|
mode: "wide"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
This test opens Airbnb in Chrome and calls `parse()` to detect every UI element on screen.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Review the source code below to understand the implementation details and patterns used.
|
|
14
|
-
|
|
15
|
-
## Live Test Run
|
|
16
|
-
|
|
17
|
-
Watch this test execute in a real sandbox environment:
|
|
11
|
+
## Watch it run
|
|
18
12
|
|
|
19
13
|
{/* parse.test.mjs output */}
|
|
20
14
|
<iframe
|
|
@@ -25,20 +19,15 @@ Watch this test execute in a real sandbox environment:
|
|
|
25
19
|
allow="fullscreen"
|
|
26
20
|
/>
|
|
27
21
|
|
|
28
|
-
##
|
|
22
|
+
## The test
|
|
29
23
|
|
|
30
24
|
```javascript title="parse.test.mjs"
|
|
31
|
-
/**
|
|
32
|
-
* TestDriver SDK - Parse Test (Vitest)
|
|
33
|
-
* Opens Airbnb and runs the .parse() SDK command to analyze the screen.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
25
|
import { describe, it } from "vitest";
|
|
37
26
|
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
38
27
|
|
|
39
28
|
describe("Parse Test", () => {
|
|
40
29
|
it("should open Airbnb and parse the screen", async (context) => {
|
|
41
|
-
const testdriver = TestDriver(context
|
|
30
|
+
const testdriver = TestDriver(context);
|
|
42
31
|
await testdriver.provision.chrome({ url: "https://www.airbnb.com" });
|
|
43
32
|
|
|
44
33
|
// The SDK automatically outputs elements as a formatted table
|
|
@@ -48,20 +37,27 @@ describe("Parse Test", () => {
|
|
|
48
37
|
});
|
|
49
38
|
```
|
|
50
39
|
|
|
51
|
-
##
|
|
40
|
+
## How it works
|
|
41
|
+
|
|
42
|
+
- `parse()` analyzes the screen and resolves to an object. Its `elements` array lists each detected element.
|
|
43
|
+
- The result also has `annotatedImageUrl`, a screenshot with the elements marked.
|
|
44
|
+
- It also has `imageWidth` and `imageHeight`.
|
|
45
|
+
- Use parsing to explore an unfamiliar screen before you write `find()` descriptions.
|
|
46
|
+
|
|
47
|
+
## Run it
|
|
48
|
+
|
|
49
|
+
The test is in the [TestDriver SDK repository](https://github.com/testdriverai/testdriverai/tree/main/examples). Clone it, install dependencies, and run the file:
|
|
52
50
|
|
|
53
51
|
```bash
|
|
54
|
-
# Clone the TestDriver repository
|
|
55
52
|
git clone https://github.com/testdriverai/testdriverai
|
|
56
|
-
|
|
57
|
-
# Install dependencies
|
|
58
53
|
cd testdriverai
|
|
59
54
|
npm install
|
|
60
|
-
|
|
61
|
-
# Run this specific example
|
|
62
|
-
vitest run examples/parse.test.mjs
|
|
55
|
+
npx vitest run examples/parse.test.mjs
|
|
63
56
|
```
|
|
64
57
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
The test reads your API key from `TD_API_KEY`. Create a key at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys). Then set it in your environment or a `.env` file.
|
|
59
|
+
|
|
60
|
+
## Related
|
|
61
|
+
|
|
62
|
+
- [parse()](/parse)
|
|
63
|
+
- [Locate elements](/locating-elements)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
3
|
-
sidebarTitle: "
|
|
4
|
-
description: "
|
|
2
|
+
title: "Use keyboard shortcuts"
|
|
3
|
+
sidebarTitle: "Press keys"
|
|
4
|
+
description: "Use pressKeys() to open a tab, open DevTools, and navigate in Chrome."
|
|
5
5
|
icon: "keyboard"
|
|
6
6
|
mode: "wide"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
This test drives Chrome with keyboard shortcuts to open tabs and DevTools, then types a URL.
|
|
10
10
|
|
|
11
|
-
Watch
|
|
11
|
+
## Watch it run
|
|
12
12
|
|
|
13
13
|
{/* press-keys.test.mjs output */}
|
|
14
14
|
<iframe
|
|
@@ -19,20 +19,15 @@ Watch this test execute in a real sandbox environment:
|
|
|
19
19
|
allow="fullscreen"
|
|
20
20
|
/>
|
|
21
21
|
|
|
22
|
-
##
|
|
23
|
-
|
|
24
|
-
```javascript title="press-keys.test.mjs" {17,24,36}
|
|
25
|
-
/**
|
|
26
|
-
* TestDriver SDK - Press Keys Test (Vitest)
|
|
27
|
-
* Converted from: testdriver/acceptance/press-keys.yaml
|
|
28
|
-
*/
|
|
22
|
+
## The test
|
|
29
23
|
|
|
24
|
+
```javascript title="press-keys.test.mjs"
|
|
30
25
|
import { describe, expect, it } from "vitest";
|
|
31
26
|
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
32
27
|
|
|
33
28
|
describe("Press Keys Test", () => {
|
|
34
29
|
it("should create tabs and navigate using keyboard shortcuts", async (context) => {
|
|
35
|
-
const testdriver = TestDriver(context
|
|
30
|
+
const testdriver = TestDriver(context);
|
|
36
31
|
await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });
|
|
37
32
|
|
|
38
33
|
const signInButton = await testdriver.find(
|
|
@@ -43,7 +38,7 @@ describe("Press Keys Test", () => {
|
|
|
43
38
|
// Open new tab
|
|
44
39
|
await testdriver.pressKeys(["ctrl", "t"]);
|
|
45
40
|
|
|
46
|
-
//
|
|
41
|
+
// Wait for the new tab page to load
|
|
47
42
|
let imagesLink = await testdriver.find("Images", {timeout: 5000});
|
|
48
43
|
|
|
49
44
|
expect(imagesLink.found()).toBeTruthy();
|
|
@@ -51,7 +46,7 @@ describe("Press Keys Test", () => {
|
|
|
51
46
|
// Open DevTools
|
|
52
47
|
await testdriver.pressKeys(["ctrl", "shift", "i"]);
|
|
53
48
|
|
|
54
|
-
//
|
|
49
|
+
// Wait for the DevTools Elements panel
|
|
55
50
|
let elements = await testdriver.find("Elements", {timeout: 5000});
|
|
56
51
|
expect(elements.found()).toBeTruthy();
|
|
57
52
|
|
|
@@ -67,20 +62,28 @@ describe("Press Keys Test", () => {
|
|
|
67
62
|
});
|
|
68
63
|
```
|
|
69
64
|
|
|
70
|
-
##
|
|
65
|
+
## How it works
|
|
66
|
+
|
|
67
|
+
- `pressKeys()` presses an array of keys together.
|
|
68
|
+
- `['ctrl', 't']` opens a new tab, and `['ctrl', 'shift', 'i']` opens DevTools.
|
|
69
|
+
- After each shortcut, `find()` with a short `timeout` waits for what the shortcut should reveal. This confirms the shortcut worked.
|
|
70
|
+
- `type()` types into the focused element, here the new tab's address bar.
|
|
71
|
+
|
|
72
|
+
## Run it
|
|
73
|
+
|
|
74
|
+
The test is in the [TestDriver SDK repository](https://github.com/testdriverai/testdriverai/tree/main/examples). Clone it, install dependencies, and run the file:
|
|
71
75
|
|
|
72
76
|
```bash
|
|
73
|
-
# Clone the TestDriver repository
|
|
74
77
|
git clone https://github.com/testdriverai/testdriverai
|
|
75
|
-
|
|
76
|
-
# Install dependencies
|
|
77
78
|
cd testdriverai
|
|
78
79
|
npm install
|
|
79
|
-
|
|
80
|
-
# Run this specific example
|
|
81
|
-
vitest run examples/press-keys.test.mjs
|
|
80
|
+
npx vitest run examples/press-keys.test.mjs
|
|
82
81
|
```
|
|
83
82
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
The test reads your API key from `TD_API_KEY`. Create a key at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys). Then set it in your environment or a `.env` file.
|
|
84
|
+
|
|
85
|
+
## Related
|
|
86
|
+
|
|
87
|
+
- [pressKeys()](/press-keys)
|
|
88
|
+
- [type()](/type)
|
|
89
|
+
- [find()](/find)
|
package/docs/examples/scroll.mdx
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
3
|
-
sidebarTitle: "
|
|
4
|
-
description: "
|
|
2
|
+
title: "Scroll a page"
|
|
3
|
+
sidebarTitle: "Scroll"
|
|
4
|
+
description: "Scroll a page down and assert that its heading has scrolled out of view."
|
|
5
5
|
icon: "scroll"
|
|
6
6
|
mode: "wide"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
This test opens a page, scrolls down, and asserts that the page heading is no longer visible.
|
|
10
10
|
|
|
11
|
-
Watch
|
|
11
|
+
## Watch it run
|
|
12
12
|
|
|
13
13
|
{/* scroll.test.mjs output */}
|
|
14
14
|
<iframe
|
|
@@ -19,26 +19,18 @@ Watch this test execute in a real sandbox environment:
|
|
|
19
19
|
allow="fullscreen"
|
|
20
20
|
/>
|
|
21
21
|
|
|
22
|
-
##
|
|
23
|
-
|
|
24
|
-
```javascript title="scroll.test.mjs" {29}
|
|
25
|
-
/**
|
|
26
|
-
* TestDriver SDK - Scroll Test (Vitest)
|
|
27
|
-
* Converted from: testdriver/acceptance/scroll.yaml
|
|
28
|
-
*
|
|
29
|
-
* UPDATED: Now using chrome preset for automatic setup
|
|
30
|
-
*/
|
|
22
|
+
## The test
|
|
31
23
|
|
|
24
|
+
```javascript title="scroll.test.mjs"
|
|
32
25
|
import { describe, expect, it } from "vitest";
|
|
33
26
|
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
34
27
|
|
|
35
28
|
describe("Scroll Test", () => {
|
|
36
29
|
it("should navigate and scroll down the page", async (context) => {
|
|
37
|
-
const testdriver = TestDriver(context
|
|
30
|
+
const testdriver = TestDriver(context);
|
|
38
31
|
await testdriver.provision.chrome({ url: 'https://www.webhamster.com/' });
|
|
39
32
|
|
|
40
|
-
|
|
41
|
-
// Wait for page to load and click heading
|
|
33
|
+
// Click the page so it has focus before scrolling
|
|
42
34
|
const heading = await testdriver.find(
|
|
43
35
|
"The Hamster Dance, large heading at top of page",
|
|
44
36
|
);
|
|
@@ -54,20 +46,26 @@ describe("Scroll Test", () => {
|
|
|
54
46
|
});
|
|
55
47
|
```
|
|
56
48
|
|
|
57
|
-
##
|
|
49
|
+
## How it works
|
|
50
|
+
|
|
51
|
+
- The test clicks the heading first so the page has focus and gets the scroll.
|
|
52
|
+
- `scroll('down', { amount: 1000 })` scrolls down with the mouse wheel. The default amount is 300.
|
|
53
|
+
- The assertion adds an exception ("It's ok if it's visible in the tab title"). This stops the AI from counting the tab title as the heading.
|
|
54
|
+
|
|
55
|
+
## Run it
|
|
56
|
+
|
|
57
|
+
The test is in the [TestDriver SDK repository](https://github.com/testdriverai/testdriverai/tree/main/examples). Clone it, install dependencies, and run the file:
|
|
58
58
|
|
|
59
59
|
```bash
|
|
60
|
-
# Clone the TestDriver repository
|
|
61
60
|
git clone https://github.com/testdriverai/testdriverai
|
|
62
|
-
|
|
63
|
-
# Install dependencies
|
|
64
61
|
cd testdriverai
|
|
65
62
|
npm install
|
|
66
|
-
|
|
67
|
-
# Run this specific example
|
|
68
|
-
vitest run examples/scroll.test.mjs
|
|
63
|
+
npx vitest run examples/scroll.test.mjs
|
|
69
64
|
```
|
|
70
65
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
The test reads your API key from `TD_API_KEY`. Create a key at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys). Then set it in your environment or a `.env` file.
|
|
67
|
+
|
|
68
|
+
## Related
|
|
69
|
+
|
|
70
|
+
- [scroll()](/scroll)
|
|
71
|
+
- [assert()](/assert)
|
package/docs/examples/type.mdx
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
3
|
-
sidebarTitle: "
|
|
4
|
-
description: "
|
|
2
|
+
title: "Type into a form"
|
|
3
|
+
sidebarTitle: "Type"
|
|
4
|
+
description: "Type into a login form and assert on the validation message for a missing password."
|
|
5
5
|
icon: "keyboard"
|
|
6
6
|
mode: "wide"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
This file has two login form tests. One types a username and checks the field. The other submits without a password and checks the browser's validation message.
|
|
10
10
|
|
|
11
|
-
Watch
|
|
11
|
+
## Watch it run
|
|
12
12
|
|
|
13
13
|
{/* type.test.mjs output */}
|
|
14
14
|
<iframe
|
|
@@ -19,18 +19,17 @@ Watch this test execute in a real sandbox environment:
|
|
|
19
19
|
allow="fullscreen"
|
|
20
20
|
/>
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## The test
|
|
23
23
|
|
|
24
|
-
```javascript title="type.test.mjs"
|
|
24
|
+
```javascript title="type.test.mjs"
|
|
25
25
|
import { describe, expect, it } from "vitest";
|
|
26
26
|
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
27
27
|
|
|
28
28
|
describe("Type Test", () => {
|
|
29
29
|
it("should enter standard_user in username field", async (context) => {
|
|
30
|
-
const testdriver = TestDriver(context
|
|
30
|
+
const testdriver = TestDriver(context);
|
|
31
31
|
await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });
|
|
32
32
|
|
|
33
|
-
//
|
|
34
33
|
const usernameField = await testdriver.find(
|
|
35
34
|
"Username, input field for username",
|
|
36
35
|
);
|
|
@@ -44,7 +43,7 @@ describe("Type Test", () => {
|
|
|
44
43
|
});
|
|
45
44
|
|
|
46
45
|
it("should show validation message when clicking Sign In without password", async (context) => {
|
|
47
|
-
const testdriver = TestDriver(context
|
|
46
|
+
const testdriver = TestDriver(context);
|
|
48
47
|
await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });
|
|
49
48
|
|
|
50
49
|
// First fill in username
|
|
@@ -54,7 +53,6 @@ describe("Type Test", () => {
|
|
|
54
53
|
await usernameField.click();
|
|
55
54
|
await testdriver.type("standard_user");
|
|
56
55
|
|
|
57
|
-
//
|
|
58
56
|
const signInButton = await testdriver.find(
|
|
59
57
|
"Sign in, black button below the password field",
|
|
60
58
|
);
|
|
@@ -69,20 +67,27 @@ describe("Type Test", () => {
|
|
|
69
67
|
});
|
|
70
68
|
```
|
|
71
69
|
|
|
72
|
-
##
|
|
70
|
+
## How it works
|
|
71
|
+
|
|
72
|
+
- `type()` types into the focused element, so each test clicks the username field first.
|
|
73
|
+
- `assert()` can check a field's contents (`the username field contains "standard_user"`) as well as on-screen messages.
|
|
74
|
+
- The second test calls `focusApplication('Google Chrome')` before asserting. This keeps Chrome in front when the validation tooltip appears.
|
|
75
|
+
|
|
76
|
+
## Run it
|
|
77
|
+
|
|
78
|
+
The test is in the [TestDriver SDK repository](https://github.com/testdriverai/testdriverai/tree/main/examples). Clone it, install dependencies, and run the file:
|
|
73
79
|
|
|
74
80
|
```bash
|
|
75
|
-
# Clone the TestDriver repository
|
|
76
81
|
git clone https://github.com/testdriverai/testdriverai
|
|
77
|
-
|
|
78
|
-
# Install dependencies
|
|
79
82
|
cd testdriverai
|
|
80
83
|
npm install
|
|
81
|
-
|
|
82
|
-
# Run this specific example
|
|
83
|
-
vitest run examples/type.test.mjs
|
|
84
|
+
npx vitest run examples/type.test.mjs
|
|
84
85
|
```
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
The test reads your API key from `TD_API_KEY`. Create a key at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys). Then set it in your environment or a `.env` file.
|
|
88
|
+
|
|
89
|
+
## Related
|
|
90
|
+
|
|
91
|
+
- [type()](/type)
|
|
92
|
+
- [click()](/click)
|
|
93
|
+
- [assert()](/assert)
|