testdriverai 7.9.0-test.4 → 7.9.0-test.40
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/sandbox.js +36 -5
- package/agent/lib/sdk.js +4 -4
- package/ai/skills/testdriver-enterprise/SKILL.md +2 -109
- package/ai/skills/testdriver-hosted/SKILL.md +156 -0
- package/ai/skills/testdriver-mcp/SKILL.md +2 -2
- package/ai/skills/testdriver-quickstart/SKILL.md +30 -2
- package/ai/skills/testdriver-self-hosted/SKILL.md +125 -43
- package/ai/skills/testdriver-test-results-json/SKILL.md +257 -0
- package/docs/_scripts/generate-examples.js +127 -60
- package/docs/docs.json +27 -28
- package/docs/v7/examples/ai.mdx +4 -3
- package/docs/v7/examples/assert.mdx +19 -4
- package/docs/v7/examples/chrome-extension.mdx +36 -29
- package/docs/v7/examples/element-not-found.mdx +2 -1
- package/docs/v7/examples/exec-output.mdx +3 -4
- package/docs/v7/examples/exec-pwsh.mdx +3 -4
- package/docs/v7/examples/findall-coffee-icons.mdx +88 -0
- package/docs/v7/examples/focus-window.mdx +3 -4
- package/docs/v7/examples/hover-image.mdx +4 -3
- package/docs/v7/examples/hover-text-with-description.mdx +104 -0
- package/docs/v7/examples/hover-text.mdx +4 -3
- package/docs/v7/examples/installer.mdx +5 -4
- package/docs/v7/examples/launch-vscode-linux.mdx +3 -7
- package/docs/v7/examples/match-image.mdx +3 -2
- package/docs/v7/examples/parse.mdx +66 -0
- package/docs/v7/examples/press-keys.mdx +8 -14
- package/docs/v7/examples/scroll-keyboard.mdx +4 -3
- package/docs/v7/examples/scroll-until-image.mdx +3 -2
- package/docs/v7/examples/scroll.mdx +6 -14
- package/docs/v7/examples/type.mdx +1 -5
- package/docs/v7/examples/windows-installer.mdx +10 -4
- package/interfaces/vitest-plugin.mjs +2 -2
- package/package.json +1 -1
- package/setup/aws/install-dev-runner.sh +7 -2
- package/setup/aws/spawn-runner.sh +12 -0
|
@@ -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
|
|
15
|
+
src="https://api.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" }}
|
|
@@ -23,7 +23,8 @@ Watch this test execute in a real sandbox environment:
|
|
|
23
23
|
|
|
24
24
|
```javascript title="press-keys.test.mjs" {17,24,36}
|
|
25
25
|
/**
|
|
26
|
-
* TestDriver SDK - Press Keys Test
|
|
26
|
+
* TestDriver SDK - Press Keys Test (Vitest)
|
|
27
|
+
* Converted from: testdriver/acceptance/press-keys.yaml
|
|
27
28
|
*/
|
|
28
29
|
|
|
29
30
|
import { describe, expect, it } from "vitest";
|
|
@@ -43,23 +44,16 @@ describe("Press Keys Test", () => {
|
|
|
43
44
|
await testdriver.pressKeys(["ctrl", "t"]);
|
|
44
45
|
|
|
45
46
|
// Poll for "Learn more" to appear
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (learnMore.found()) break;
|
|
50
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
51
|
-
}
|
|
47
|
+
let imagesLink = await testdriver.find("Images", {timeout: 5000});
|
|
48
|
+
|
|
49
|
+
expect(imagesLink.found()).toBeTruthy();
|
|
52
50
|
|
|
53
51
|
// Open DevTools
|
|
54
52
|
await testdriver.pressKeys(["ctrl", "shift", "i"]);
|
|
55
53
|
|
|
56
54
|
// Poll for "Elements" to appear
|
|
57
|
-
let elements = await testdriver.find("Elements");
|
|
58
|
-
|
|
59
|
-
elements = await elements.find();
|
|
60
|
-
if (elements.found()) break;
|
|
61
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
62
|
-
}
|
|
55
|
+
let elements = await testdriver.find("Elements", {timeout: 5000});
|
|
56
|
+
expect(elements.found()).toBeTruthy();
|
|
63
57
|
|
|
64
58
|
// Open another tab and navigate
|
|
65
59
|
await testdriver.pressKeys(["ctrl", "t"]);
|
|
@@ -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
|
|
15
|
+
src="https://api.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" }}
|
|
@@ -23,7 +23,8 @@ Watch this test execute in a real sandbox environment:
|
|
|
23
23
|
|
|
24
24
|
```javascript title="scroll-keyboard.test.mjs" {26}
|
|
25
25
|
/**
|
|
26
|
-
* TestDriver SDK - Scroll Keyboard Test
|
|
26
|
+
* TestDriver SDK - Scroll Keyboard Test (Vitest)
|
|
27
|
+
* Converted from: testdriver/acceptance/scroll-keyboard.yaml
|
|
27
28
|
*/
|
|
28
29
|
|
|
29
30
|
import { describe, expect, it } from "vitest";
|
|
@@ -38,7 +39,7 @@ describe("Scroll Keyboard Test", () => {
|
|
|
38
39
|
// Navigate to https://www.webhamster.com/
|
|
39
40
|
await testdriver.focusApplication("Google Chrome");
|
|
40
41
|
const urlBar = await testdriver.find(
|
|
41
|
-
"
|
|
42
|
+
"the URL in the omnibox", {zoom: true}
|
|
42
43
|
);
|
|
43
44
|
await urlBar.click();
|
|
44
45
|
await testdriver.pressKeys(["ctrl", "a"]);
|
|
@@ -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
|
|
15
|
+
src="https://api.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" }}
|
|
@@ -23,7 +23,8 @@ Watch this test execute in a real sandbox environment:
|
|
|
23
23
|
|
|
24
24
|
```javascript title="scroll-until-image.test.mjs" {26}
|
|
25
25
|
/**
|
|
26
|
-
* TestDriver SDK - Scroll Until Image Test
|
|
26
|
+
* TestDriver SDK - Scroll Until Image Test (Vitest)
|
|
27
|
+
* Converted from: testdriver/acceptance/scroll-until-image.yaml
|
|
27
28
|
*/
|
|
28
29
|
|
|
29
30
|
import { describe, expect, it } from "vitest";
|
|
@@ -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
|
|
15
|
+
src="https://api.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" }}
|
|
@@ -23,7 +23,10 @@ Watch this test execute in a real sandbox environment:
|
|
|
23
23
|
|
|
24
24
|
```javascript title="scroll.test.mjs" {29}
|
|
25
25
|
/**
|
|
26
|
-
* TestDriver SDK - Scroll Test
|
|
26
|
+
* TestDriver SDK - Scroll Test (Vitest)
|
|
27
|
+
* Converted from: testdriver/acceptance/scroll.yaml
|
|
28
|
+
*
|
|
29
|
+
* UPDATED: Now using chrome preset for automatic setup
|
|
27
30
|
*/
|
|
28
31
|
|
|
29
32
|
import { describe, expect, it } from "vitest";
|
|
@@ -32,19 +35,8 @@ import { TestDriver } from "testdriverai/vitest/hooks";
|
|
|
32
35
|
describe("Scroll Test", () => {
|
|
33
36
|
it("should navigate and scroll down the page", async (context) => {
|
|
34
37
|
const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP, headless: true });
|
|
35
|
-
await testdriver.provision.chrome({ url: '
|
|
38
|
+
await testdriver.provision.chrome({ url: 'https://www.webhamster.com/' });
|
|
36
39
|
|
|
37
|
-
// Give Chrome a moment to fully render the UI
|
|
38
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
39
|
-
|
|
40
|
-
// Navigate to webhamster.com - just look for the domain, not the full path
|
|
41
|
-
const urlBar = await testdriver.find(
|
|
42
|
-
"testdriver-sandbox.vercel.app, the URL in the address bar",
|
|
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
40
|
|
|
49
41
|
// Wait for page to load and click heading
|
|
50
42
|
const heading = await testdriver.find(
|
|
@@ -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
|
|
15
|
+
src="https://api.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" }}
|
|
@@ -22,10 +22,6 @@ Watch this test execute in a real sandbox environment:
|
|
|
22
22
|
## Source Code
|
|
23
23
|
|
|
24
24
|
```javascript title="type.test.mjs" {13}
|
|
25
|
-
/**
|
|
26
|
-
* TestDriver SDK - Type Test
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
25
|
import { describe, expect, it } from "vitest";
|
|
30
26
|
import { TestDriver } from "testdriverai/vitest/hooks";
|
|
31
27
|
|
|
@@ -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
|
|
15
|
+
src="https://api.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" }}
|
|
@@ -23,7 +23,14 @@ Watch this test execute in a real sandbox environment:
|
|
|
23
23
|
|
|
24
24
|
```javascript title="windows-installer.test.mjs" {22-25}
|
|
25
25
|
/**
|
|
26
|
-
* TestDriver SDK - Windows Installer Example
|
|
26
|
+
* TestDriver SDK - Windows Installer Example (Vitest)
|
|
27
|
+
*
|
|
28
|
+
* This example demonstrates how to download and install a Windows application
|
|
29
|
+
* using PowerShell commands, then launch and interact with it.
|
|
30
|
+
*
|
|
31
|
+
* Based on the v6 GitButler provisioning workflow.
|
|
32
|
+
*
|
|
33
|
+
* Run: TD_OS=windows vitest run examples/windows-installer.test.mjs
|
|
27
34
|
*/
|
|
28
35
|
|
|
29
36
|
import { describe, it } from "vitest";
|
|
@@ -35,8 +42,7 @@ describe("Windows App Installation", () => {
|
|
|
35
42
|
|
|
36
43
|
it.skipIf(isLinux)("should download, install, and launch GitButler on Windows", async (context) => {
|
|
37
44
|
// Alternative approach using provision.installer helper
|
|
38
|
-
const testdriver = TestDriver(context, {
|
|
39
|
-
ip: context.ip || process.env.TD_IP,
|
|
45
|
+
const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP,
|
|
40
46
|
os: 'windows'
|
|
41
47
|
});
|
|
42
48
|
|
|
@@ -412,9 +412,9 @@ export async function authenticateWithApiKey(apiKey, apiRoot) {
|
|
|
412
412
|
if (response.status >= 500) {
|
|
413
413
|
const serverError = new Error(
|
|
414
414
|
data.message ||
|
|
415
|
-
`
|
|
415
|
+
`An error occurred on the TestDriver server (HTTP ${response.status}). Please try again later.`,
|
|
416
416
|
);
|
|
417
|
-
serverError.code = data.error || "
|
|
417
|
+
serverError.code = data.error || "SERVER_ERROR";
|
|
418
418
|
serverError.isServerError = true;
|
|
419
419
|
throw serverError;
|
|
420
420
|
}
|
package/package.json
CHANGED
|
@@ -33,6 +33,9 @@ url = sys.argv[1]
|
|
|
33
33
|
|
|
34
34
|
commands = [
|
|
35
35
|
"Write-Host '=== Stopping runner ==='",
|
|
36
|
+
"New-Item -ItemType Directory -Path 'C:\\testdriver\\sandbox-agent' -Force | Out-Null",
|
|
37
|
+
"New-Item -ItemType Directory -Path 'C:\\testdriver\\logs' -Force | Out-Null",
|
|
38
|
+
"if (-not (Test-Path 'C:\\testdriver\\sandbox-agent\\package.json')) { '{\"name\":\"td-sandbox\",\"private\":true}' | Set-Content 'C:\\testdriver\\sandbox-agent\\package.json' }",
|
|
36
39
|
"Stop-ScheduledTask -TaskName RunTestDriverAgent -ErrorAction SilentlyContinue",
|
|
37
40
|
"Stop-Process -Name node -Force -ErrorAction SilentlyContinue",
|
|
38
41
|
"Start-Sleep -Seconds 2",
|
|
@@ -43,10 +46,12 @@ commands = [
|
|
|
43
46
|
"Remove-Item -Path lib -Recurse -Force -ErrorAction SilentlyContinue",
|
|
44
47
|
"tar -xzf $tarball --strip-components=1 -C .",
|
|
45
48
|
"Get-Content 'package.json' | ConvertFrom-Json | Select-Object -ExpandProperty version",
|
|
49
|
+
"Write-Host '=== Ensuring scheduled task exists ==='",
|
|
50
|
+
"if (-not (Get-ScheduledTask -TaskName RunTestDriverAgent -ErrorAction SilentlyContinue)) { $agentScript = if (Test-Path 'sandbox-agent.js') { 'sandbox-agent.js' } else { 'node_modules/@testdriverai/runner/sandbox-agent.js' }; @(\"Set-Location 'C:\\testdriver\\sandbox-agent'\", \"while (`$true) { & node $agentScript 2>&1 | Tee-Object -Append -FilePath C:\\testdriver\\logs\\sandbox-agent.log; Start-Sleep -Seconds 2 }\") | Set-Content 'C:\\testdriver\\run_testdriver.ps1'; $a = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-ExecutionPolicy Bypass -NoProfile -WindowStyle Hidden -File C:\\testdriver\\run_testdriver.ps1'; $t = New-ScheduledTaskTrigger -AtLogOn -User 'testdriver'; $p = New-ScheduledTaskPrincipal -UserId 'testdriver' -RunLevel Highest; $s = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -StartWhenAvailable; Register-ScheduledTask -TaskName RunTestDriverAgent -Action $a -Trigger $t -Principal $p -Settings $s -Force }",
|
|
46
51
|
"Write-Host '=== Starting runner ==='",
|
|
47
|
-
"Start-ScheduledTask -TaskName RunTestDriverAgent",
|
|
52
|
+
"Start-ScheduledTask -TaskName RunTestDriverAgent -ErrorAction SilentlyContinue",
|
|
48
53
|
"Start-Sleep -Seconds 3",
|
|
49
|
-
"Get-Content 'C:\\testdriver\\log.txt' -Tail 20"
|
|
54
|
+
"Get-Content 'C:\\testdriver\\log.txt' -Tail 20 -ErrorAction SilentlyContinue"
|
|
50
55
|
]
|
|
51
56
|
|
|
52
57
|
params = {"commands": commands}
|
|
@@ -183,6 +183,10 @@ if [ "$TD_CHANNEL" = "dev" ]; then
|
|
|
183
183
|
{
|
|
184
184
|
"commands": [
|
|
185
185
|
"Write-Host '=== Starting runner dev install ==='",
|
|
186
|
+
"Write-Host 'Bootstrapping sandbox-agent directory...'",
|
|
187
|
+
"New-Item -ItemType Directory -Path 'C:\\testdriver\\sandbox-agent' -Force | Out-Null",
|
|
188
|
+
"New-Item -ItemType Directory -Path 'C:\\testdriver\\logs' -Force | Out-Null",
|
|
189
|
+
"if (-not (Test-Path 'C:\\testdriver\\sandbox-agent\\package.json')) { '{\"name\":\"td-sandbox\",\"private\":true}' | Set-Content 'C:\\testdriver\\sandbox-agent\\package.json' }",
|
|
186
190
|
"Write-Host 'Stopping existing runner processes...'",
|
|
187
191
|
"Stop-ScheduledTask -TaskName RunTestDriverAgent -ErrorAction SilentlyContinue",
|
|
188
192
|
"Stop-Process -Name node -Force -ErrorAction SilentlyContinue",
|
|
@@ -220,6 +224,8 @@ PARAMS_EOF
|
|
|
220
224
|
"npm install --omit=dev 2>&1 | Write-Host",
|
|
221
225
|
"Write-Host 'Final verification - ably-service.js exists:'",
|
|
222
226
|
"Test-Path 'C:\\testdriver\\sandbox-agent\\lib\\ably-service.js'",
|
|
227
|
+
"Write-Host 'Ensuring scheduled task exists...'",
|
|
228
|
+
"if (-not (Get-ScheduledTask -TaskName RunTestDriverAgent -ErrorAction SilentlyContinue)) { $agentScript = if (Test-Path 'C:\\testdriver\\sandbox-agent\\sandbox-agent.js') { 'sandbox-agent.js' } else { 'node_modules/@testdriverai/runner/sandbox-agent.js' }; @(\"Set-Location 'C:\\testdriver\\sandbox-agent'\", \"while (`$true) { & node $agentScript 2>&1 | Tee-Object -Append -FilePath C:\\testdriver\\logs\\sandbox-agent.log; Start-Sleep -Seconds 2 }\") | Set-Content 'C:\\testdriver\\run_testdriver.ps1'; $a = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-ExecutionPolicy Bypass -NoProfile -WindowStyle Hidden -File C:\\testdriver\\run_testdriver.ps1'; $t = New-ScheduledTaskTrigger -AtLogOn -User 'testdriver'; $p = New-ScheduledTaskPrincipal -UserId 'testdriver' -RunLevel Highest; $s = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -StartWhenAvailable; Register-ScheduledTask -TaskName RunTestDriverAgent -Action $a -Trigger $t -Principal $p -Settings $s -Force }",
|
|
223
229
|
"Write-Host 'Restarting RunTestDriverAgent scheduled task...'",
|
|
224
230
|
"Start-ScheduledTask -TaskName RunTestDriverAgent -ErrorAction SilentlyContinue",
|
|
225
231
|
"Write-Host '=== Runner install complete (dev) ==='"
|
|
@@ -245,6 +251,10 @@ else
|
|
|
245
251
|
{
|
|
246
252
|
"commands": [
|
|
247
253
|
"Write-Host '=== Starting runner install (npm pack) ==='",
|
|
254
|
+
"Write-Host 'Bootstrapping sandbox-agent directory...'",
|
|
255
|
+
"New-Item -ItemType Directory -Path 'C:\\\\testdriver\\\\sandbox-agent' -Force | Out-Null",
|
|
256
|
+
"New-Item -ItemType Directory -Path 'C:\\\\testdriver\\\\logs' -Force | Out-Null",
|
|
257
|
+
"if (-not (Test-Path 'C:\\\\testdriver\\\\sandbox-agent\\\\package.json')) { '{\"name\":\"td-sandbox\",\"private\":true}' | Set-Content 'C:\\\\testdriver\\\\sandbox-agent\\\\package.json' }",
|
|
248
258
|
"Write-Host 'Stopping existing runner processes...'",
|
|
249
259
|
"Stop-ScheduledTask -TaskName RunTestDriverAgent -ErrorAction SilentlyContinue",
|
|
250
260
|
"Stop-Process -Name node -Force -ErrorAction SilentlyContinue",
|
|
@@ -271,6 +281,8 @@ else
|
|
|
271
281
|
"Set-Location 'C:\\\\testdriver\\\\sandbox-agent'",
|
|
272
282
|
"Write-Host 'Installing npm dependencies...'",
|
|
273
283
|
"npm install --omit=dev 2>&1 | Write-Host",
|
|
284
|
+
"Write-Host 'Ensuring scheduled task exists...'",
|
|
285
|
+
"if (-not (Get-ScheduledTask -TaskName RunTestDriverAgent -ErrorAction SilentlyContinue)) { \$agentScript = if (Test-Path 'C:\\\\testdriver\\\\sandbox-agent\\\\sandbox-agent.js') { 'sandbox-agent.js' } else { 'node_modules/@testdriverai/runner/sandbox-agent.js' }; @(\"Set-Location 'C:\\\\testdriver\\\\sandbox-agent'\", \"while (\`\$true) { & node \$agentScript 2>&1 | Tee-Object -Append -FilePath C:\\\\testdriver\\\\logs\\\\sandbox-agent.log; Start-Sleep -Seconds 2 }\") | Set-Content 'C:\\\\testdriver\\\\run_testdriver.ps1'; \$a = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-ExecutionPolicy Bypass -NoProfile -WindowStyle Hidden -File C:\\\\testdriver\\\\run_testdriver.ps1'; \$t = New-ScheduledTaskTrigger -AtLogOn -User 'testdriver'; \$p = New-ScheduledTaskPrincipal -UserId 'testdriver' -RunLevel Highest; \$s = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -StartWhenAvailable; Register-ScheduledTask -TaskName RunTestDriverAgent -Action \$a -Trigger \$t -Principal \$p -Settings \$s -Force }",
|
|
274
286
|
"Write-Host 'Restarting RunTestDriverAgent scheduled task...'",
|
|
275
287
|
"Start-ScheduledTask -TaskName RunTestDriverAgent -ErrorAction SilentlyContinue",
|
|
276
288
|
"Write-Host '=== Runner install complete (npm pack) ==='"
|