testdriverai 7.2.30 ā 7.2.31
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
CHANGED
|
@@ -356,8 +356,9 @@ const createCommands = (
|
|
|
356
356
|
);
|
|
357
357
|
|
|
358
358
|
// Wait for redraw and track duration
|
|
359
|
+
// Increase timeout for scroll operations as they can take 1-2 seconds to complete
|
|
359
360
|
const redrawStartTime = Date.now();
|
|
360
|
-
await redraw.wait(
|
|
361
|
+
await redraw.wait(5000, redrawOptions);
|
|
361
362
|
const redrawDuration = Date.now() - redrawStartTime;
|
|
362
363
|
|
|
363
364
|
const after = await system.captureScreenBase64();
|
package/docs/v7/quickstart.mdx
CHANGED
package/package.json
CHANGED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TestDriver SDK - API Resilience Test
|
|
3
|
-
*
|
|
4
|
-
* This test verifies that TestDriver client can handle API restarts gracefully.
|
|
5
|
-
* It will:
|
|
6
|
-
* 1. Start a sandbox and browser
|
|
7
|
-
* 2. Make some API calls (TestDriver operations)
|
|
8
|
-
* 3. Kill the API (dev.sh)
|
|
9
|
-
* 4. Restart the API
|
|
10
|
-
* 5. Continue making API calls and verify they work
|
|
11
|
-
*
|
|
12
|
-
* Usage:
|
|
13
|
-
* npm test -- test/api-resilience.test.mjs
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { describe, expect, it } from "vitest";
|
|
17
|
-
import { TestDriver } from "../lib/vitest/hooks.mjs";
|
|
18
|
-
import { spawn, exec } from 'child_process';
|
|
19
|
-
import { promisify } from 'util';
|
|
20
|
-
|
|
21
|
-
const execAsync = promisify(exec);
|
|
22
|
-
|
|
23
|
-
describe("API Resilience Test", () => {
|
|
24
|
-
it("should continue working after API restart", async (context) => {
|
|
25
|
-
const testdriver = TestDriver(context, {
|
|
26
|
-
newSandbox: true,
|
|
27
|
-
headless: false
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
console.log("\nš Step 1: Provision Chrome and navigate to test page");
|
|
31
|
-
await testdriver.provision.chrome({
|
|
32
|
-
url: 'http://testdriver-sandbox.vercel.app/login',
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
console.log("ā
Provisioned successfully");
|
|
36
|
-
|
|
37
|
-
console.log("\nš Step 2: Perform initial test operations");
|
|
38
|
-
const button1 = await testdriver.find("Sign In button");
|
|
39
|
-
console.log("ā
Found Sign In button:", button1.found());
|
|
40
|
-
expect(button1.found()).toBe(true);
|
|
41
|
-
|
|
42
|
-
const result1 = await testdriver.assert("I can see a login page");
|
|
43
|
-
console.log("ā
First assertion passed:", result1);
|
|
44
|
-
expect(result1).toBeTruthy();
|
|
45
|
-
|
|
46
|
-
console.log("\nš Step 3: Simulate API going down");
|
|
47
|
-
console.log("ā ļø Killing dev.sh process...");
|
|
48
|
-
|
|
49
|
-
try {
|
|
50
|
-
// Kill all node processes running app.js (the API server)
|
|
51
|
-
await execAsync("pkill -f 'node.*app.js'");
|
|
52
|
-
console.log("ā
API killed");
|
|
53
|
-
} catch (error) {
|
|
54
|
-
// pkill returns non-zero exit code if no processes found, which is okay
|
|
55
|
-
console.log("Note: No app.js processes found to kill (or already killed)");
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Wait a bit to ensure API is down
|
|
59
|
-
console.log("ā³ Waiting 3 seconds to ensure API is down...");
|
|
60
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
61
|
-
|
|
62
|
-
console.log("\nš Step 4: Restart API");
|
|
63
|
-
console.log("š Starting dev.sh...");
|
|
64
|
-
|
|
65
|
-
// Start dev.sh in background
|
|
66
|
-
const apiProcess = spawn('bash', ['dev.sh'], {
|
|
67
|
-
cwd: '/Users/ianjennings/Development/api',
|
|
68
|
-
detached: true,
|
|
69
|
-
stdio: 'ignore'
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// Unref so the process doesn't keep this test running
|
|
73
|
-
apiProcess.unref();
|
|
74
|
-
|
|
75
|
-
console.log("ā
API restarted (PID:", apiProcess.pid, ")");
|
|
76
|
-
|
|
77
|
-
// Wait for API to be ready
|
|
78
|
-
console.log("ā³ Waiting 10 seconds for API to initialize...");
|
|
79
|
-
await new Promise(resolve => setTimeout(resolve, 10000));
|
|
80
|
-
|
|
81
|
-
console.log("\nš Step 5: Continue test operations after API restart");
|
|
82
|
-
console.log("š Attempting to find element again...");
|
|
83
|
-
|
|
84
|
-
const button2 = await testdriver.find("Sign In button");
|
|
85
|
-
console.log("ā
Found Sign In button again:", button2.found());
|
|
86
|
-
expect(button2.found()).toBe(true);
|
|
87
|
-
|
|
88
|
-
console.log("š Performing another assertion...");
|
|
89
|
-
const result2 = await testdriver.assert("I can see a login page");
|
|
90
|
-
console.log("ā
Second assertion passed:", result2);
|
|
91
|
-
expect(result2).toBeTruthy();
|
|
92
|
-
|
|
93
|
-
console.log("\nš Step 6: Perform additional operations to verify full functionality");
|
|
94
|
-
const emailInput = await testdriver.find("email input field");
|
|
95
|
-
console.log("ā
Found email input:", emailInput.found());
|
|
96
|
-
expect(emailInput.found()).toBe(true);
|
|
97
|
-
|
|
98
|
-
await emailInput.click();
|
|
99
|
-
await testdriver.type("test@example.com");
|
|
100
|
-
console.log("ā
Typed into email field");
|
|
101
|
-
|
|
102
|
-
const result3 = await testdriver.assert("the email field contains text");
|
|
103
|
-
console.log("ā
Final assertion passed:", result3);
|
|
104
|
-
expect(result3).toBeTruthy();
|
|
105
|
-
|
|
106
|
-
console.log("\nš Test completed successfully! API resilience verified.");
|
|
107
|
-
});
|
|
108
|
-
}, {
|
|
109
|
-
timeout: 120000 // 2 minute timeout for this test
|
|
110
|
-
});
|
|
@@ -35,7 +35,7 @@ describe("Scroll Test", () => {
|
|
|
35
35
|
await testdriver.scroll("down", { amount: 1000 });
|
|
36
36
|
|
|
37
37
|
// Assert page is scrolled
|
|
38
|
-
const result = await testdriver.assert("the page is scrolled down, the hamster dance heading is not visible on the
|
|
38
|
+
const result = await testdriver.assert("the page is scrolled down, the hamster dance h1 text heading is not visible on the webpage");
|
|
39
39
|
expect(result).toBeTruthy();
|
|
40
40
|
});
|
|
41
41
|
});
|