testdriverai 7.9.2-test → 7.9.3-canary
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/agent/lib/commands.js +22 -6
- package/docs/_scripts/generate-examples.js +20 -6
- package/docs/docs.json +1 -0
- package/docs/v7/examples/ai.mdx +1 -1
- package/docs/v7/examples/assert.mdx +1 -1
- package/docs/v7/examples/chrome-extension.mdx +1 -1
- package/docs/v7/examples/element-not-found.mdx +1 -1
- package/docs/v7/examples/exec-output.mdx +1 -1
- package/docs/v7/examples/exec-pwsh.mdx +1 -1
- package/docs/v7/examples/exec-stream-logs.mdx +65 -0
- package/docs/v7/examples/findall-coffee-icons.mdx +3 -2
- package/docs/v7/examples/focus-window.mdx +1 -1
- package/docs/v7/examples/formatted-logging.mdx +74 -0
- package/docs/v7/examples/hover-image.mdx +1 -1
- package/docs/v7/examples/hover-text-with-description.mdx +1 -1
- package/docs/v7/examples/hover-text.mdx +1 -1
- package/docs/v7/examples/installer.mdx +1 -1
- package/docs/v7/examples/launch-vscode-linux.mdx +1 -1
- package/docs/v7/examples/match-image.mdx +1 -1
- package/docs/v7/examples/parse.mdx +1 -1
- package/docs/v7/examples/press-keys.mdx +1 -1
- package/docs/v7/examples/prompt.mdx +81 -0
- package/docs/v7/examples/scroll-keyboard.mdx +1 -1
- package/docs/v7/examples/scroll-until-image.mdx +1 -1
- package/docs/v7/examples/scroll.mdx +1 -1
- package/docs/v7/examples/type.mdx +1 -1
- package/docs/v7/examples/windows-installer.mdx +1 -1
- package/{manual → examples}/exec-stream-logs.test.mjs +1 -1
- package/package.json +1 -1
package/agent/lib/commands.js
CHANGED
|
@@ -1565,11 +1565,26 @@ const createCommands = (
|
|
|
1565
1565
|
let result = null;
|
|
1566
1566
|
|
|
1567
1567
|
const execTimeout = timeout || 300000;
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1568
|
+
|
|
1569
|
+
// Stream output chunks in real-time as they arrive from the runner
|
|
1570
|
+
let streamedOutput = false;
|
|
1571
|
+
const onExecOutput = ({ chunk }) => {
|
|
1572
|
+
if (!silent && chunk) {
|
|
1573
|
+
emitter.emit(events.log.log, theme.dim(chunk), true);
|
|
1574
|
+
streamedOutput = true;
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
emitter.on(events.exec.output, onExecOutput);
|
|
1578
|
+
|
|
1579
|
+
try {
|
|
1580
|
+
result = await sandbox.send({
|
|
1581
|
+
type: "commands.run",
|
|
1582
|
+
command: code,
|
|
1583
|
+
timeout: execTimeout,
|
|
1584
|
+
}, execTimeout);
|
|
1585
|
+
} finally {
|
|
1586
|
+
emitter.off(events.exec.output, onExecOutput);
|
|
1587
|
+
}
|
|
1573
1588
|
|
|
1574
1589
|
const execActionEndTime = Date.now();
|
|
1575
1590
|
const execDuration = execActionEndTime - execActionLogStart;
|
|
@@ -1595,7 +1610,8 @@ const createCommands = (
|
|
|
1595
1610
|
true,
|
|
1596
1611
|
);
|
|
1597
1612
|
|
|
1598
|
-
if
|
|
1613
|
+
// Skip stdout log if already streamed in real-time to avoid duplication
|
|
1614
|
+
if (!silent && !streamedOutput && result.out?.stdout) {
|
|
1599
1615
|
emitter.emit(events.log.log, theme.dim(` stdout:`), true);
|
|
1600
1616
|
emitter.emit(events.log.log, theme.dim(` ${result.out.stdout}`), true);
|
|
1601
1617
|
}
|
|
@@ -279,22 +279,36 @@ function extractTestcaseId(url) {
|
|
|
279
279
|
return pathParts.length >= 2 ? pathParts[pathParts.length - 1] : null;
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
+
// Derive API root from a console URL (e.g. console-test.testdriver.ai → api-test.testdriver.ai)
|
|
283
|
+
function apiRootFromConsoleUrl(sourceUrl) {
|
|
284
|
+
if (!sourceUrl) return null;
|
|
285
|
+
try {
|
|
286
|
+
const url = new URL(sourceUrl);
|
|
287
|
+
// Map console* hostname to api* hostname
|
|
288
|
+
const apiHostname = url.hostname.replace(/^console/, 'api');
|
|
289
|
+
return `${url.protocol}//${apiHostname}`;
|
|
290
|
+
} catch {
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
282
295
|
// Generate replay URL from testcase ID
|
|
283
|
-
|
|
296
|
+
// sourceUrl is the manifest URL used to infer the correct API environment
|
|
297
|
+
function generateReplayUrl(testcaseId, sourceUrl) {
|
|
284
298
|
// Use the API replay endpoint which handles the redirect with embed=true
|
|
285
|
-
const apiRoot = process.env.TD_API_ROOT || 'https://api.testdriver.ai';
|
|
299
|
+
const apiRoot = apiRootFromConsoleUrl(sourceUrl) || process.env.TD_API_ROOT || 'https://api.testdriver.ai';
|
|
286
300
|
return `${apiRoot}/api/v1/testdriver/testcase/${testcaseId}/replay`;
|
|
287
301
|
}
|
|
288
302
|
|
|
289
303
|
// Update existing MDX file by finding the marker comment and replacing the iframe
|
|
290
|
-
function updateExistingMDX(existingContent, filename, testcaseId) {
|
|
304
|
+
function updateExistingMDX(existingContent, filename, testcaseId, sourceUrl) {
|
|
291
305
|
const marker = `{/* ${filename} output */}`;
|
|
292
306
|
|
|
293
307
|
if (!existingContent.includes(marker)) {
|
|
294
308
|
return null; // Marker not found, can't update
|
|
295
309
|
}
|
|
296
310
|
|
|
297
|
-
const replayUrl = generateReplayUrl(testcaseId);
|
|
311
|
+
const replayUrl = generateReplayUrl(testcaseId, sourceUrl);
|
|
298
312
|
|
|
299
313
|
// Pattern to match the marker followed by the iframe tag
|
|
300
314
|
const escapedFilename = filename.replace(/\./g, '\\.');
|
|
@@ -356,7 +370,7 @@ ${description}
|
|
|
356
370
|
|
|
357
371
|
// Add Live Test Run section if URL exists
|
|
358
372
|
if (testcaseId) {
|
|
359
|
-
const replayUrl = generateReplayUrl(testcaseId);
|
|
373
|
+
const replayUrl = generateReplayUrl(testcaseId, manifestEntry?.url);
|
|
360
374
|
mdx += `## Live Test Run
|
|
361
375
|
|
|
362
376
|
Watch this test execute in a real sandbox environment:
|
|
@@ -562,7 +576,7 @@ async function main() {
|
|
|
562
576
|
const manifestEntry = manifest.examples[testMeta.filename];
|
|
563
577
|
const testcaseId = manifestEntry?.url ? extractTestcaseId(manifestEntry.url) : null;
|
|
564
578
|
if (testcaseId) {
|
|
565
|
-
const iframeUpdated = updateExistingMDX(content, testMeta.filename, testcaseId);
|
|
579
|
+
const iframeUpdated = updateExistingMDX(content, testMeta.filename, testcaseId, manifestEntry.url);
|
|
566
580
|
if (iframeUpdated && iframeUpdated !== content) {
|
|
567
581
|
content = iframeUpdated;
|
|
568
582
|
changed = true;
|
package/docs/docs.json
CHANGED
package/docs/v7/examples/ai.mdx
CHANGED
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* ai.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d04ac2e6e94933886778/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d04ac2e6e94933886778/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* assert.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d038058ffe89003c6adc/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d038058ffe89003c6adc/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* chrome-extension.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d024c2e6e94933886763/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d024c2e6e94933886763/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* element-not-found.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d047058ffe89003c6ae4/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d047058ffe89003c6ae4/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* exec-output.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d02ee8a04db4b705cbeb/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d02ee8a04db4b705cbeb/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* exec-pwsh.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d026a0a3ef8239de4746/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d026a0a3ef8239de4746/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Exec Log Streaming"
|
|
3
|
+
sidebarTitle: "Exec Stream Logs"
|
|
4
|
+
description: "Example: should stream exec logs every second for 20 seconds"
|
|
5
|
+
icon: "terminal"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
This example demonstrates the "Exec Log Streaming" test suite. Specifically, it shows how to should stream exec logs every second for 20 seconds.
|
|
11
|
+
|
|
12
|
+
Review the source code below to understand the implementation details and patterns used.
|
|
13
|
+
|
|
14
|
+
## Live Test Run
|
|
15
|
+
|
|
16
|
+
<Note>
|
|
17
|
+
A live test recording will be available after the next CI run.
|
|
18
|
+
</Note>
|
|
19
|
+
|
|
20
|
+
## Source Code
|
|
21
|
+
|
|
22
|
+
```javascript title="exec-stream-logs.test.mjs"
|
|
23
|
+
import { describe, expect, it } from "vitest";
|
|
24
|
+
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
25
|
+
|
|
26
|
+
describe("Exec Log Streaming", () => {
|
|
27
|
+
it("should stream exec logs every second for 20 seconds", async (context) => {
|
|
28
|
+
const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP, headless: true });
|
|
29
|
+
await testdriver.provision.chrome({ url: "about:blank" });
|
|
30
|
+
|
|
31
|
+
const code = `for i in $(seq 1 20); do echo "log line $i at $(date +%T)"; sleep 1; done`;
|
|
32
|
+
|
|
33
|
+
const result = await testdriver.exec({
|
|
34
|
+
language: "sh",
|
|
35
|
+
code,
|
|
36
|
+
timeout: 30000,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
console.log("exec result:", result);
|
|
40
|
+
|
|
41
|
+
// Verify we got all 20 log lines
|
|
42
|
+
for (let i = 1; i <= 20; i++) {
|
|
43
|
+
expect(result).toContain(`log line ${i}`);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Running This Example
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Clone the TestDriver repository
|
|
53
|
+
git clone https://github.com/testdriverai/testdriverai
|
|
54
|
+
|
|
55
|
+
# Install dependencies
|
|
56
|
+
cd testdriverai
|
|
57
|
+
npm install
|
|
58
|
+
|
|
59
|
+
# Run this specific example
|
|
60
|
+
npx vitest run examples/exec-stream-logs.test.mjs
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
<Note>
|
|
64
|
+
Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
|
|
65
|
+
</Note>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "FindAll
|
|
2
|
+
title: "FindAll"
|
|
3
3
|
sidebarTitle: "Findall Coffee Icons"
|
|
4
4
|
description: "TestDriver SDK - FindAll Coffee Icons Test Loads a random icon grid and uses findAll() to locate and click all 4 coffee cup icons."
|
|
5
5
|
icon: "play"
|
|
6
|
+
mode: "wide"
|
|
6
7
|
---
|
|
7
8
|
|
|
8
9
|
## Overview
|
|
@@ -17,7 +18,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
17
18
|
|
|
18
19
|
{/* findall-coffee-icons.test.mjs output */}
|
|
19
20
|
<iframe
|
|
20
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d03ae8a04db4b705cbf0/replay"
|
|
21
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d03ae8a04db4b705cbf0/replay"
|
|
21
22
|
width="100%"
|
|
22
23
|
height="600"
|
|
23
24
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* focus-window.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d042e8a04db4b705cbf2/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d042e8a04db4b705cbf2/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -0,0 +1,74 @@
|
|
|
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/69c5d045058ffe89003c6ae1/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
|
+
npx 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>
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* hover-image.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d0300201196437256cd3/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d0300201196437256cd3/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -18,7 +18,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
18
18
|
|
|
19
19
|
{/* hover-text-with-description.test.mjs output */}
|
|
20
20
|
<iframe
|
|
21
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d029c2e6e94933886764/replay"
|
|
21
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d029c2e6e94933886764/replay"
|
|
22
22
|
width="100%"
|
|
23
23
|
height="600"
|
|
24
24
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* hover-text.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d04b0201196437256ce6/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d04b0201196437256ce6/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* installer.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d032c2e6e94933886769/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d032c2e6e94933886769/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* launch-vscode-linux.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d02be8a04db4b705cbe5/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d02be8a04db4b705cbe5/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* match-image.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d0270201196437256ccf/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d0270201196437256ccf/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -17,7 +17,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
17
17
|
|
|
18
18
|
{/* parse.test.mjs output */}
|
|
19
19
|
<iframe
|
|
20
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d04d0201196437256ce7/replay"
|
|
20
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d04d0201196437256ce7/replay"
|
|
21
21
|
width="100%"
|
|
22
22
|
height="600"
|
|
23
23
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* press-keys.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d036058ffe89003c6ada/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d036058ffe89003c6ada/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Prompt"
|
|
3
|
+
sidebarTitle: "Prompt"
|
|
4
|
+
description: "TestDriver SDK - Prompt Test (Vitest) Converted from: testdriver/acceptance/prompt.yaml."
|
|
5
|
+
icon: "message"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
TestDriver SDK - Prompt Test (Vitest) Converted from: testdriver/acceptance/prompt.yaml
|
|
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
|
+
{/* prompt.test.mjs output */}
|
|
19
|
+
<iframe
|
|
20
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d040c2e6e9493388676f/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="prompt.test.mjs"
|
|
30
|
+
/**
|
|
31
|
+
* TestDriver SDK - Prompt Test (Vitest)
|
|
32
|
+
* Converted from: testdriver/acceptance/prompt.yaml
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
import { describe, expect, it } from "vitest";
|
|
36
|
+
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
37
|
+
|
|
38
|
+
describe.skip("Prompt Test", () => {
|
|
39
|
+
it("should execute AI-driven prompts", 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
|
+
//
|
|
44
|
+
// Note: The SDK doesn't have a direct equivalent to YAML prompts without commands.
|
|
45
|
+
// This would typically be handled by the AI agent interpreting natural language.
|
|
46
|
+
// For SDK usage, you need to use explicit commands.
|
|
47
|
+
|
|
48
|
+
// Original prompts were:
|
|
49
|
+
// 1. "log in"
|
|
50
|
+
// 2. "add an item to the cart"
|
|
51
|
+
// 3. "click on the cart icon"
|
|
52
|
+
// 4. "complete checkout"
|
|
53
|
+
|
|
54
|
+
// This test is skipped as it requires explicit SDK implementation
|
|
55
|
+
// You would need to implement these as explicit SDK calls
|
|
56
|
+
|
|
57
|
+
await testdriver.act("log in");
|
|
58
|
+
|
|
59
|
+
const result = await testdriver.assert("the testdriver sandbox is visible");
|
|
60
|
+
expect(result).toBeTruthy();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Running This Example
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Clone the TestDriver repository
|
|
69
|
+
git clone https://github.com/testdriverai/testdriverai
|
|
70
|
+
|
|
71
|
+
# Install dependencies
|
|
72
|
+
cd testdriverai
|
|
73
|
+
npm install
|
|
74
|
+
|
|
75
|
+
# Run this specific example
|
|
76
|
+
npx vitest run examples/prompt.test.mjs
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
<Note>
|
|
80
|
+
Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
|
|
81
|
+
</Note>
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* scroll-keyboard.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d03da0a3ef8239de474f/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d03da0a3ef8239de474f/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* scroll-until-image.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d03f0201196437256cda/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d03f0201196437256cda/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* scroll.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d043058ffe89003c6ae0/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d043058ffe89003c6ae0/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* type.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d034c2e6e9493388676c/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d034c2e6e9493388676c/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -12,7 +12,7 @@ Watch this test execute in a real sandbox environment:
|
|
|
12
12
|
|
|
13
13
|
{/* windows-installer.test.mjs output */}
|
|
14
14
|
<iframe
|
|
15
|
-
src="https://api.testdriver.ai/api/v1/testdriver/testcase/69c5d02ce8a04db4b705cbe9/replay"
|
|
15
|
+
src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d02ce8a04db4b705cbe9/replay"
|
|
16
16
|
width="100%"
|
|
17
17
|
height="390"
|
|
18
18
|
style={{ border: "1px solid #333", borderRadius: "8px" }}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
import { TestDriver } from "../lib/vitest/hooks.mjs";
|
|
3
|
-
import { getDefaults } from "
|
|
3
|
+
import { getDefaults } from "./config.mjs";
|
|
4
4
|
|
|
5
5
|
describe("Exec Log Streaming", () => {
|
|
6
6
|
it("should stream exec logs every second for 20 seconds", async (context) => {
|