@testdriverai/agent 7.11.229-test → 7.11.232-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 +79 -22
- 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 +26 -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,92 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Captcha Solving Example"
|
|
3
|
-
sidebarTitle: "Captcha Solving"
|
|
4
|
-
description: "Example test demonstrating automatic captcha solving with reCAPTCHA and Cloudflare Turnstile support."
|
|
5
|
-
icon: "shield-check"
|
|
6
|
-
mode: "wide"
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Demo Test Run
|
|
10
|
-
|
|
11
|
-
Watch this test execute in a real sandbox environment:
|
|
12
|
-
|
|
13
|
-
{/* captcha-api.test.mjs output */}
|
|
14
|
-
<iframe
|
|
15
|
-
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/698f7fb0d3b320ad547d9d44/replay"
|
|
16
|
-
width="100%"
|
|
17
|
-
height="390"
|
|
18
|
-
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
19
|
-
allow="fullscreen"
|
|
20
|
-
/>
|
|
21
|
-
|
|
22
|
-
## Source Code
|
|
23
|
-
|
|
24
|
-
```javascript title="captcha-api.test.mjs" {18-20}
|
|
25
|
-
/**
|
|
26
|
-
* TestDriver SDK - Captcha Test
|
|
27
|
-
*/
|
|
28
|
-
import { describe, expect, it } from "vitest";
|
|
29
|
-
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
30
|
-
|
|
31
|
-
console.log("DEBUG: process.env.TD_OS:", process.env.TD_OS);
|
|
32
|
-
|
|
33
|
-
describe("testdriver.captcha() API", () => {
|
|
34
|
-
it("should solve reCAPTCHA v3 with auto-detect", async (context) => {
|
|
35
|
-
const testdriver = TestDriver(context);
|
|
36
|
-
|
|
37
|
-
// Launch Chrome (remote debugging is enabled automatically on Linux)
|
|
38
|
-
await testdriver.provision.chrome({
|
|
39
|
-
url: "https://2captcha.com/demo/recaptcha-v3",
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
await testdriver.screenshot();
|
|
43
|
-
|
|
44
|
-
// Solve the captcha with just the API key - everything else is auto-detected!
|
|
45
|
-
const result = await testdriver.captcha({
|
|
46
|
-
apiKey: process.env.TWOCAPTCHA_API_KEY,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
console.log("Captcha result:", result);
|
|
50
|
-
await testdriver.screenshot();
|
|
51
|
-
|
|
52
|
-
expect(result.success).toBe(true);
|
|
53
|
-
}, 180000);
|
|
54
|
-
|
|
55
|
-
it("should solve Cloudflare Turnstile", async (context) => {
|
|
56
|
-
const testdriver = TestDriver(context);
|
|
57
|
-
|
|
58
|
-
await testdriver.provision.chrome({
|
|
59
|
-
url: "https://2captcha.com/demo/cloudflare-turnstile",
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
await testdriver.screenshot();
|
|
63
|
-
|
|
64
|
-
const result = await testdriver.captcha({
|
|
65
|
-
apiKey: process.env.TWOCAPTCHA_API_KEY,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
console.log("Turnstile result:", result);
|
|
69
|
-
await testdriver.screenshot();
|
|
70
|
-
|
|
71
|
-
expect(result.success).toBe(true);
|
|
72
|
-
}, 180000);
|
|
73
|
-
});
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Running This Example
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
# Clone the TestDriver repository
|
|
80
|
-
git clone https://github.com/testdriverai/testdriverai
|
|
81
|
-
|
|
82
|
-
# Install dependencies
|
|
83
|
-
cd testdriverai
|
|
84
|
-
npm install
|
|
85
|
-
|
|
86
|
-
# Run this specific example
|
|
87
|
-
vitest run examples/captcha-api.test.mjs
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
<Note>
|
|
91
|
-
Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
|
|
92
|
-
</Note>
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Chrome Extension Test Example"
|
|
3
|
-
sidebarTitle: "Chrome Extension"
|
|
4
|
-
description: "Example test showing how to load Chrome extensions from local paths or the Chrome Web Store."
|
|
5
|
-
icon: "chrome"
|
|
6
|
-
mode: "wide"
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Demo Test Run
|
|
10
|
-
|
|
11
|
-
Watch this test execute in a real sandbox environment:
|
|
12
|
-
|
|
13
|
-
{/* chrome-extension.test.mjs output */}
|
|
14
|
-
<iframe
|
|
15
|
-
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6a8798913062df0fb9b85592/replay"
|
|
16
|
-
width="100%"
|
|
17
|
-
height="390"
|
|
18
|
-
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
19
|
-
allow="fullscreen"
|
|
20
|
-
/>
|
|
21
|
-
|
|
22
|
-
## Source Code
|
|
23
|
-
|
|
24
|
-
```javascript title="chrome-extension.test.mjs" {31-33}
|
|
25
|
-
/**
|
|
26
|
-
* TestDriver SDK - Chrome Extension Test (Vitest)
|
|
27
|
-
* Tests loading a Chrome extension using provision.chromeExtension()
|
|
28
|
-
*
|
|
29
|
-
* This test suite covers:
|
|
30
|
-
* 1. Loading extension from local path (extensionPath)
|
|
31
|
-
* 2. Loading extension from Chrome Web Store (extensionId)
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
import { describe, expect, it } from "vitest";
|
|
35
|
-
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
36
|
-
|
|
37
|
-
describe("Chrome Extension Test", () => {
|
|
38
|
-
it("should load hello-world Chrome extension from local path", async (context) => {
|
|
39
|
-
|
|
40
|
-
console.log('connecting to', process.env.TD_IP)
|
|
41
|
-
|
|
42
|
-
const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP, cacheKey: new Date().getTime().toString() });
|
|
43
|
-
|
|
44
|
-
// Determine OS-specific paths and commands
|
|
45
|
-
const shell = testdriver.os === 'windows' ? 'pwsh' : 'sh';
|
|
46
|
-
const extensionsDir = testdriver.os === 'windows'
|
|
47
|
-
? 'C:\\Users\\testdriver\\Downloads\\chrome-extensions-samples'
|
|
48
|
-
: '/tmp/chrome-extensions-samples';
|
|
49
|
-
const extensionPath = testdriver.os === 'windows'
|
|
50
|
-
? `${extensionsDir}\\functional-samples\\tutorial.hello-world`
|
|
51
|
-
: `${extensionsDir}/functional-samples/tutorial.hello-world`;
|
|
52
|
-
|
|
53
|
-
// Clone the Chrome extensions samples repo
|
|
54
|
-
const cloneCmd = testdriver.os === 'windows'
|
|
55
|
-
? `git clone --depth 1 https://github.com/GoogleChrome/chrome-extensions-samples.git "${extensionsDir}"`
|
|
56
|
-
: `git clone --depth 1 https://github.com/GoogleChrome/chrome-extensions-samples.git ${extensionsDir}`;
|
|
57
|
-
|
|
58
|
-
await testdriver.exec(shell, cloneCmd, 60000, true);
|
|
59
|
-
|
|
60
|
-
// Launch Chrome with the hello-world extension loaded
|
|
61
|
-
await testdriver.provision.chromeExtension({
|
|
62
|
-
extensionPath: extensionPath
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Navigate to testdriver.ai (extensions don't load on New Tab)
|
|
66
|
-
const addressBar = await testdriver.find("Chrome address bar");
|
|
67
|
-
await addressBar.click();
|
|
68
|
-
await testdriver.type("testdriver.ai");
|
|
69
|
-
await testdriver.pressKeys(["enter"]);
|
|
70
|
-
|
|
71
|
-
// Wait for page to load
|
|
72
|
-
const pageResult = await testdriver.assert("I can see testdriver.ai");
|
|
73
|
-
expect(pageResult).toBeTruthy();
|
|
74
|
-
|
|
75
|
-
// The hello-world extension adds a puzzle piece icon to the toolbar
|
|
76
|
-
// When clicked, it shows a popup with "Hello Extensions"
|
|
77
|
-
|
|
78
|
-
// Retry opening the extension popup and verifying it up to 3 times
|
|
79
|
-
let popupResult;
|
|
80
|
-
let lastError;
|
|
81
|
-
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
82
|
-
try {
|
|
83
|
-
// Click on the extensions button (puzzle piece icon) in Chrome toolbar
|
|
84
|
-
const extensionsButton = await testdriver.find("The extensions button in the Chrome toolbar", {zoom: true, verify: true, timeout: 10000});
|
|
85
|
-
await extensionsButton.click();
|
|
86
|
-
|
|
87
|
-
// Look for the hello world extension in the extensions menu
|
|
88
|
-
const helloExtension = await testdriver.find("Hello Extensions extension in the extensions dropdown", {zoom: true, verify: true, timeout: 10000});
|
|
89
|
-
await helloExtension.click();
|
|
90
|
-
|
|
91
|
-
await testdriver.wait(2000); // wait for the popup to open
|
|
92
|
-
|
|
93
|
-
// Verify the extension popup shows "Hello Extensions" text
|
|
94
|
-
popupResult = await testdriver.assert("a popup shows with the text 'Hello Extensions'");
|
|
95
|
-
if (popupResult) break;
|
|
96
|
-
} catch (err) {
|
|
97
|
-
lastError = err;
|
|
98
|
-
console.log(`Attempt ${attempt} failed:`, err.message);
|
|
99
|
-
}
|
|
100
|
-
if (attempt < 3) {
|
|
101
|
-
// Dismiss any open popup/menu before retrying
|
|
102
|
-
await testdriver.pressKeys(["escape"]);
|
|
103
|
-
await testdriver.wait(1000);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (!popupResult && lastError) throw lastError;
|
|
107
|
-
expect(popupResult).toBeTruthy();
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// it("should load Loom from Chrome Web Store by extensionId", async (context) => {
|
|
111
|
-
// const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP});
|
|
112
|
-
|
|
113
|
-
// // Launch Chrome with Loom loaded by its Chrome Web Store ID
|
|
114
|
-
// // Loom ID: liecbddmkiiihnedobmlmillhodjkdmb
|
|
115
|
-
// await testdriver.provision.chromeExtension({
|
|
116
|
-
// extensionId: 'liecbddmkiiihnedobmlmillhodjkdmb'
|
|
117
|
-
// });
|
|
118
|
-
|
|
119
|
-
// // Navigate to testdriver.ai (extensions don't load on New Tab)
|
|
120
|
-
// const addressBar = await testdriver.find("Chrome address bar");
|
|
121
|
-
// await addressBar.click();
|
|
122
|
-
// await testdriver.type("testdriver.ai");
|
|
123
|
-
// await testdriver.pressKeys(["enter"]);
|
|
124
|
-
|
|
125
|
-
// // Wait for page to load
|
|
126
|
-
// const pageResult = await testdriver.assert("I can see testdriver.ai");
|
|
127
|
-
// expect(pageResult).toBeTruthy();
|
|
128
|
-
|
|
129
|
-
// // Click on the extensions button (puzzle piece icon) in Chrome toolbar
|
|
130
|
-
// const extensionsButton = await testdriver.find("The puzzle-shaped icon in the Chrome toolbar.", {zoom: true});
|
|
131
|
-
// await extensionsButton.click();
|
|
132
|
-
|
|
133
|
-
// // Look for Loom in the extensions menu
|
|
134
|
-
// const loomExtension = await testdriver.find("Loom extension in the extensions dropdown");
|
|
135
|
-
// expect(loomExtension.found()).toBeTruthy();
|
|
136
|
-
// });
|
|
137
|
-
});
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## Running This Example
|
|
141
|
-
|
|
142
|
-
```bash
|
|
143
|
-
# Clone the TestDriver repository
|
|
144
|
-
git clone https://github.com/testdriverai/testdriverai
|
|
145
|
-
|
|
146
|
-
# Install dependencies
|
|
147
|
-
cd testdriverai
|
|
148
|
-
npm install
|
|
149
|
-
|
|
150
|
-
# Run this specific example
|
|
151
|
-
vitest run examples/chrome-extension.test.mjs
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
<Note>
|
|
155
|
-
Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
|
|
156
|
-
</Note>
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Drag and Drop Test Example"
|
|
3
|
-
sidebarTitle: "Drag and Drop"
|
|
4
|
-
description: "Example test demonstrating drag and drop interactions using mouseDown and mouseUp."
|
|
5
|
-
icon: "arrows-up-down-left-right"
|
|
6
|
-
mode: "wide"
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Demo Test Run
|
|
10
|
-
|
|
11
|
-
Watch this test execute in a real sandbox environment:
|
|
12
|
-
|
|
13
|
-
{/* drag-and-drop.test.mjs output */}
|
|
14
|
-
<iframe
|
|
15
|
-
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69a62b42fc0ac3cc632a918b/replay"
|
|
16
|
-
width="100%"
|
|
17
|
-
height="390"
|
|
18
|
-
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
19
|
-
allow="fullscreen"
|
|
20
|
-
/>
|
|
21
|
-
|
|
22
|
-
## Source Code
|
|
23
|
-
|
|
24
|
-
```javascript title="drag-and-drop.test.mjs" {33-34,38-39}
|
|
25
|
-
/**
|
|
26
|
-
* TestDriver SDK - Drag and Drop Test
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
import { describe, expect, it } from "vitest";
|
|
30
|
-
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
31
|
-
|
|
32
|
-
const isLinux = (process.env.TD_OS || "linux") === "linux";
|
|
33
|
-
|
|
34
|
-
describe("Drag and Drop Test", () => {
|
|
35
|
-
it.skipIf(isLinux)(
|
|
36
|
-
'should drag "New Text Document" to "Recycle Bin"',
|
|
37
|
-
async (context) => {
|
|
38
|
-
const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP, headless: true });
|
|
39
|
-
await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });
|
|
40
|
-
|
|
41
|
-
//
|
|
42
|
-
// Show the desktop
|
|
43
|
-
await testdriver.pressKeys(["win", "d"]);
|
|
44
|
-
|
|
45
|
-
// Open the context menu
|
|
46
|
-
await testdriver.pressKeys(["shift", "f10"]);
|
|
47
|
-
|
|
48
|
-
// Hover over "New" in the context menu
|
|
49
|
-
const newOption = await testdriver.find(
|
|
50
|
-
"New, new option in the open context menu on the desktop",
|
|
51
|
-
);
|
|
52
|
-
await newOption.hover();
|
|
53
|
-
|
|
54
|
-
// Click "Text Document" in the context menu
|
|
55
|
-
const textDocOption = await testdriver.find(
|
|
56
|
-
"Text Document, text document option in the new submenu of the desktop context menu",
|
|
57
|
-
);
|
|
58
|
-
await textDocOption.click();
|
|
59
|
-
|
|
60
|
-
// Unfocus the "Text Document" text field
|
|
61
|
-
await testdriver.pressKeys(["esc"]);
|
|
62
|
-
|
|
63
|
-
// Drag the "New Text Document" icon to the "Recycle Bin"
|
|
64
|
-
const textDoc = await testdriver.find(
|
|
65
|
-
"New Text Document, new text document icon in the center of the desktop",
|
|
66
|
-
);
|
|
67
|
-
await textDoc.mouseDown();
|
|
68
|
-
|
|
69
|
-
const recycleBin = await testdriver.find(
|
|
70
|
-
"Recycle Bin, recycle bin icon in the top left corner of the desktop",
|
|
71
|
-
);
|
|
72
|
-
await recycleBin.mouseUp();
|
|
73
|
-
|
|
74
|
-
// Assert "New Text Document" icon is not on the Desktop
|
|
75
|
-
const result = await testdriver.assert(
|
|
76
|
-
'the "New Text Document" icon is not visible on the Desktop',
|
|
77
|
-
);
|
|
78
|
-
expect(result).toBeTruthy();
|
|
79
|
-
},
|
|
80
|
-
);
|
|
81
|
-
});
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Running This Example
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
# Clone the TestDriver repository
|
|
88
|
-
git clone https://github.com/testdriverai/testdriverai
|
|
89
|
-
|
|
90
|
-
# Install dependencies
|
|
91
|
-
cd testdriverai
|
|
92
|
-
npm install
|
|
93
|
-
|
|
94
|
-
# Run this specific example
|
|
95
|
-
vitest run examples/drag-and-drop.test.mjs
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
<Note>
|
|
99
|
-
Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
|
|
100
|
-
</Note>
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Formatted Logging Test"
|
|
3
|
-
sidebarTitle: "Formatted Logging"
|
|
4
|
-
description: "TestDriver SDK - Formatted Logging Demo Demonstrates nice Vitest-style formatted logs for Dashcam replay."
|
|
5
|
-
icon: "play"
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Overview
|
|
9
|
-
|
|
10
|
-
TestDriver SDK - Formatted Logging Demo Demonstrates nice Vitest-style formatted logs for Dashcam replay
|
|
11
|
-
|
|
12
|
-
Review the source code below to understand the implementation details and patterns used.
|
|
13
|
-
|
|
14
|
-
## Live Test Run
|
|
15
|
-
|
|
16
|
-
Watch this test execute in a real sandbox environment:
|
|
17
|
-
|
|
18
|
-
{/* formatted-logging.test.mjs output */}
|
|
19
|
-
<iframe
|
|
20
|
-
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c873a714b73310c7839450/replay"
|
|
21
|
-
width="100%"
|
|
22
|
-
height="600"
|
|
23
|
-
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
24
|
-
allow="fullscreen"
|
|
25
|
-
/>
|
|
26
|
-
|
|
27
|
-
## Source Code
|
|
28
|
-
|
|
29
|
-
```javascript title="formatted-logging.test.mjs"
|
|
30
|
-
/**
|
|
31
|
-
* TestDriver SDK - Formatted Logging Demo
|
|
32
|
-
* Demonstrates nice Vitest-style formatted logs for Dashcam replay
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
import { describe, expect, it } from "vitest";
|
|
36
|
-
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
37
|
-
|
|
38
|
-
describe("Formatted Logging Test", () => {
|
|
39
|
-
it("should demonstrate formatted logs in dashcam replay", async (context) => {
|
|
40
|
-
const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP, headless: true });
|
|
41
|
-
await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });
|
|
42
|
-
|
|
43
|
-
// Find and click - logs will be nicely formatted
|
|
44
|
-
const signInButton = await testdriver.find(
|
|
45
|
-
"Sign In, black button below the password field",
|
|
46
|
-
);
|
|
47
|
-
await signInButton.click();
|
|
48
|
-
|
|
49
|
-
// Assert - logs will show pass/fail with nice formatting
|
|
50
|
-
const result = await testdriver.assert(
|
|
51
|
-
"an error shows that fields are required",
|
|
52
|
-
);
|
|
53
|
-
expect(result).toBeTruthy();
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Running This Example
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
# Clone the TestDriver repository
|
|
62
|
-
git clone https://github.com/testdriverai/testdriverai
|
|
63
|
-
|
|
64
|
-
# Install dependencies
|
|
65
|
-
cd testdriverai
|
|
66
|
-
npm install
|
|
67
|
-
|
|
68
|
-
# Run this specific example
|
|
69
|
-
vitest run examples/formatted-logging.test.mjs
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
<Note>
|
|
73
|
-
Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
|
|
74
|
-
</Note>
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Clicking on Text Example"
|
|
3
|
-
sidebarTitle: "Hover Text"
|
|
4
|
-
description: "Example test that finds and clicks on text elements using natural language descriptions."
|
|
5
|
-
icon: "hand-pointer"
|
|
6
|
-
mode: "wide"
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Demo Test Run
|
|
10
|
-
|
|
11
|
-
Watch this test execute in a real sandbox environment:
|
|
12
|
-
|
|
13
|
-
{/* hover-text.test.mjs output */}
|
|
14
|
-
<iframe
|
|
15
|
-
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6ad6b60a022b6043aeec2bf1/replay"
|
|
16
|
-
width="100%"
|
|
17
|
-
height="390"
|
|
18
|
-
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
19
|
-
allow="fullscreen"
|
|
20
|
-
/>
|
|
21
|
-
|
|
22
|
-
## Source Code
|
|
23
|
-
|
|
24
|
-
```javascript title="hover-text.test.mjs" {13-15,18-20}
|
|
25
|
-
/**
|
|
26
|
-
* TestDriver SDK - Hover Text Test (Vitest)
|
|
27
|
-
* Converted from: testdriver/acceptance/hover-text.yaml
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
import { describe, expect, it } from "vitest";
|
|
31
|
-
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
32
|
-
|
|
33
|
-
describe("Hover Text Test", () => {
|
|
34
|
-
it("should click Sign In and verify error message", async (context) => {
|
|
35
|
-
const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP});
|
|
36
|
-
await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });
|
|
37
|
-
|
|
38
|
-
// Click on Sign In button using new find() API
|
|
39
|
-
|
|
40
|
-
const signInButton = await testdriver.find(
|
|
41
|
-
"Sign In, black button below the password field",
|
|
42
|
-
);
|
|
43
|
-
await signInButton.click();
|
|
44
|
-
|
|
45
|
-
// Assert that an error shows that fields are required
|
|
46
|
-
const result = await testdriver.assert(
|
|
47
|
-
"an error shows that fields are required",
|
|
48
|
-
);
|
|
49
|
-
expect(result).toBeTruthy();
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Running This Example
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
# Clone the TestDriver repository
|
|
58
|
-
git clone https://github.com/testdriverai/testdriverai
|
|
59
|
-
|
|
60
|
-
# Install dependencies
|
|
61
|
-
cd testdriverai
|
|
62
|
-
npm install
|
|
63
|
-
|
|
64
|
-
# Run this specific example
|
|
65
|
-
vitest run examples/hover-text.test.mjs
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
<Note>
|
|
69
|
-
Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
|
|
70
|
-
</Note>
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Matching an Image By Pixel"
|
|
3
|
-
sidebarTitle: "Pixel Based Match"
|
|
4
|
-
description: "Example test demonstrating pixel-based image matching to locate UI elements."
|
|
5
|
-
icon: "image"
|
|
6
|
-
mode: "wide"
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Demo Test Run
|
|
10
|
-
|
|
11
|
-
Watch this test execute in a real sandbox environment:
|
|
12
|
-
|
|
13
|
-
{/* match-image.test.mjs output */}
|
|
14
|
-
<iframe
|
|
15
|
-
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c8738c14b73310c783941d/replay"
|
|
16
|
-
width="100%"
|
|
17
|
-
height="390"
|
|
18
|
-
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
19
|
-
allow="fullscreen"
|
|
20
|
-
/>
|
|
21
|
-
|
|
22
|
-
## Source Code
|
|
23
|
-
|
|
24
|
-
```javascript title="match-image.test.mjs" {42}
|
|
25
|
-
/**
|
|
26
|
-
* TestDriver SDK - Match Image Test (Vitest)
|
|
27
|
-
* Converted from: testdriver/acceptance/match-image.yaml
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
import path, { dirname } from "path";
|
|
31
|
-
import { fileURLToPath } from "url";
|
|
32
|
-
import { describe, expect, it } from "vitest";
|
|
33
|
-
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Perform login flow for SauceLabs demo app
|
|
37
|
-
* @param {TestDriver} client - TestDriver client
|
|
38
|
-
* @param {string} username - Username (default: 'standard_user')
|
|
39
|
-
*/
|
|
40
|
-
async function performLogin(client, username = "standard_user") {
|
|
41
|
-
await client.focusApplication("Google Chrome");
|
|
42
|
-
const password = await client.extract("the password");
|
|
43
|
-
const usernameField = await client.find(
|
|
44
|
-
"username input",
|
|
45
|
-
);
|
|
46
|
-
await usernameField.click();
|
|
47
|
-
await client.type(username);
|
|
48
|
-
await client.pressKeys(["tab"]);
|
|
49
|
-
await client.type(password, { secret: true });
|
|
50
|
-
await client.pressKeys(["tab"]);
|
|
51
|
-
await client.pressKeys(["enter"]);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Get the directory of the current module
|
|
55
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
56
|
-
const __dirname = dirname(__filename);
|
|
57
|
-
|
|
58
|
-
describe("Match Image Test", () => {
|
|
59
|
-
it.skip("should match shopping cart image and verify empty cart", async (context) => {
|
|
60
|
-
const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP, headless: true });
|
|
61
|
-
await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });
|
|
62
|
-
|
|
63
|
-
//
|
|
64
|
-
// Perform login first
|
|
65
|
-
await performLogin(testdriver);
|
|
66
|
-
|
|
67
|
-
// Match and click the shopping cart icon
|
|
68
|
-
const cartImagePath = path.resolve(
|
|
69
|
-
__dirname,
|
|
70
|
-
"../../_testdriver/acceptance/screenshots/cart.png",
|
|
71
|
-
);
|
|
72
|
-
await testdriver.matchImage(cartImagePath, "click");
|
|
73
|
-
|
|
74
|
-
// Assert that you see an empty shopping cart
|
|
75
|
-
const result = await testdriver.assert("Your cart is empty");
|
|
76
|
-
expect(result).toBeTruthy();
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
## Running This Example
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
# Clone the TestDriver repository
|
|
85
|
-
git clone https://github.com/testdriverai/testdriverai
|
|
86
|
-
|
|
87
|
-
# Install dependencies
|
|
88
|
-
cd testdriverai
|
|
89
|
-
npm install
|
|
90
|
-
|
|
91
|
-
# Run this specific example
|
|
92
|
-
vitest run examples/match-image.test.mjs
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
<Note>
|
|
96
|
-
Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
|
|
97
|
-
</Note>
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Scrolling with Keyboard Test Example"
|
|
3
|
-
sidebarTitle: "Scrolling with Keyboard"
|
|
4
|
-
description: "Example test demonstrating page scrolling using keyboard-based scroll controls."
|
|
5
|
-
icon: "scroll"
|
|
6
|
-
mode: "wide"
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Demo Test Run
|
|
10
|
-
|
|
11
|
-
Watch this test execute in a real sandbox environment:
|
|
12
|
-
|
|
13
|
-
{/* scroll-keyboard.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
|
-
## Source Code
|
|
23
|
-
|
|
24
|
-
```javascript title="scroll-keyboard.test.mjs" {26}
|
|
25
|
-
/**
|
|
26
|
-
* TestDriver SDK - Scroll Keyboard Test (Vitest)
|
|
27
|
-
* Converted from: testdriver/acceptance/scroll-keyboard.yaml
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
import { describe, expect, it } from "vitest";
|
|
31
|
-
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
32
|
-
|
|
33
|
-
describe("Scroll Keyboard Test", () => {
|
|
34
|
-
it("should navigate to webhamster.com and scroll with keyboard", async (context) => {
|
|
35
|
-
const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP, headless: true });
|
|
36
|
-
await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });
|
|
37
|
-
|
|
38
|
-
//
|
|
39
|
-
// Navigate to https://www.webhamster.com/
|
|
40
|
-
await testdriver.focusApplication("Google Chrome");
|
|
41
|
-
const urlBar = await testdriver.find(
|
|
42
|
-
"the URL in the omnibox", {zoom: true}
|
|
43
|
-
);
|
|
44
|
-
await urlBar.click();
|
|
45
|
-
await testdriver.pressKeys(["ctrl", "a"]);
|
|
46
|
-
await testdriver.type("https://www.webhamster.com/");
|
|
47
|
-
await testdriver.pressKeys(["enter"]);
|
|
48
|
-
|
|
49
|
-
// Scroll down with keyboard 1000 pixels
|
|
50
|
-
const heading = await testdriver.find(
|
|
51
|
-
"The Hamster Dance, large heading at top of page",
|
|
52
|
-
);
|
|
53
|
-
await heading.click();
|
|
54
|
-
await testdriver.scroll("down", { amount: 1000 });
|
|
55
|
-
|
|
56
|
-
// Assert the page is scrolled down
|
|
57
|
-
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.");
|
|
58
|
-
|
|
59
|
-
expect(result).toBeTruthy();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Running This Example
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
# Clone the TestDriver repository
|
|
68
|
-
git clone https://github.com/testdriverai/testdriverai
|
|
69
|
-
|
|
70
|
-
# Install dependencies
|
|
71
|
-
cd testdriverai
|
|
72
|
-
npm install
|
|
73
|
-
|
|
74
|
-
# Run this specific example
|
|
75
|
-
vitest run examples/scroll-keyboard.test.mjs
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
<Note>
|
|
79
|
-
Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
|
|
80
|
-
</Note>
|