testdriverai 7.2.12 → 7.2.13
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/.testdriver/last-sandbox +3 -3
- package/agent/lib/commander.js +0 -2
- package/agent/lib/commands.js +16 -23
- package/package.json +1 -1
- package/test/testdriver/chrome-extension.test.mjs +2 -3
- package/test/testdriver/act.test.mjs +0 -30
- package/tests/example.test.js +0 -33
- package/tests/login.js +0 -28
- package/tests/table-sort-enrollments.test.mjs +0 -72
- package/tests/table-sort-experiment.test.mjs +0 -42
- package/tests/table-sort-setup.test.mjs +0 -59
package/.testdriver/last-sandbox
CHANGED
package/agent/lib/commander.js
CHANGED
|
@@ -110,10 +110,8 @@ commands:
|
|
|
110
110
|
case "hover-text":
|
|
111
111
|
emitter.emit(events.log.log, generator.jsonToManual(object));
|
|
112
112
|
response = await commands["hover-text"](
|
|
113
|
-
object.text,
|
|
114
113
|
object.description,
|
|
115
114
|
object.action,
|
|
116
|
-
object.method,
|
|
117
115
|
object.timeout,
|
|
118
116
|
);
|
|
119
117
|
break;
|
package/agent/lib/commands.js
CHANGED
|
@@ -719,47 +719,40 @@ const createCommands = (
|
|
|
719
719
|
hover: hover,
|
|
720
720
|
/**
|
|
721
721
|
* Hover over text on screen
|
|
722
|
-
* @param {Object|string} options - Options object or
|
|
723
|
-
* @param {string} options.
|
|
724
|
-
* @param {string|null} [options.description] - Optional description of the element
|
|
722
|
+
* @param {Object|string} options - Options object or description (for backward compatibility)
|
|
723
|
+
* @param {string} options.description - Description of the element to find
|
|
725
724
|
* @param {string} [options.action='click'] - Action to perform
|
|
726
725
|
* @param {number} [options.timeout=5000] - Timeout in milliseconds
|
|
727
726
|
*/
|
|
728
727
|
"hover-text": async (...args) => {
|
|
729
|
-
let
|
|
728
|
+
let description, action, timeout;
|
|
730
729
|
|
|
731
730
|
// Handle both object and positional argument styles
|
|
732
|
-
if (isObjectArgs(args, ['
|
|
733
|
-
({
|
|
731
|
+
if (isObjectArgs(args, ['description', 'action', 'timeout'])) {
|
|
732
|
+
({ description, action = 'click', timeout = 5000 } = args[0]);
|
|
734
733
|
} else {
|
|
735
|
-
// Legacy positional: hoverText(
|
|
736
|
-
[
|
|
734
|
+
// Legacy positional: hoverText(description, action, timeout)
|
|
735
|
+
[description, action = 'click', timeout = 5000] = args;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
if (!description) {
|
|
739
|
+
throw new CommandError("hover-text requires a description parameter");
|
|
737
740
|
}
|
|
738
741
|
|
|
742
|
+
description = description.toString();
|
|
743
|
+
|
|
739
744
|
emitter.emit(
|
|
740
745
|
events.log.narration,
|
|
741
|
-
theme.dim(
|
|
742
|
-
`searching for "${text}"${description ? ` (${description})` : ""}...`,
|
|
743
|
-
),
|
|
746
|
+
theme.dim(`searching for "${description}"...`),
|
|
744
747
|
);
|
|
745
748
|
|
|
746
|
-
text = text ? text.toString() : null;
|
|
747
|
-
|
|
748
749
|
// wait for the text to appear on screen
|
|
749
|
-
await commands["wait-for-text"]({ text, timeout });
|
|
750
|
-
|
|
751
|
-
description = description ? description.toString() : null;
|
|
750
|
+
await commands["wait-for-text"]({ text: description, timeout });
|
|
752
751
|
|
|
753
752
|
emitter.emit(events.log.narration, theme.dim("thinking..."), true);
|
|
754
753
|
|
|
755
|
-
// Combine text and description into element parameter
|
|
756
|
-
let element = text;
|
|
757
|
-
if (description) {
|
|
758
|
-
element = `"${text}" with description ${description}`;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
754
|
let response = await sdk.req("find", {
|
|
762
|
-
element,
|
|
755
|
+
element: description,
|
|
763
756
|
image: await system.captureScreenBase64(),
|
|
764
757
|
});
|
|
765
758
|
|
package/package.json
CHANGED
|
@@ -35,7 +35,7 @@ describe("Chrome Extension Test", () => {
|
|
|
35
35
|
// When clicked, it shows a popup with "Hello Extensions"
|
|
36
36
|
|
|
37
37
|
// First, let's verify Chrome loaded and we can see the page
|
|
38
|
-
const pageResult = await testdriver.assert("the
|
|
38
|
+
const pageResult = await testdriver.assert("the google.com website is visible");
|
|
39
39
|
expect(pageResult).toBeTruthy();
|
|
40
40
|
|
|
41
41
|
// Click on the extensions button (puzzle piece icon) in Chrome toolbar
|
|
@@ -57,8 +57,7 @@ describe("Chrome Extension Test", () => {
|
|
|
57
57
|
// Launch Chrome with Loom loaded by its Chrome Web Store ID
|
|
58
58
|
// Loom ID: liecbddmkiiihnedobmlmillhodjkdmb
|
|
59
59
|
await testdriver.provision.chromeExtension({
|
|
60
|
-
extensionId: 'liecbddmkiiihnedobmlmillhodjkdmb'
|
|
61
|
-
url: 'https://testdriver.ai'
|
|
60
|
+
extensionId: 'liecbddmkiiihnedobmlmillhodjkdmb'
|
|
62
61
|
});
|
|
63
62
|
|
|
64
63
|
// Click on the extensions button (puzzle piece icon) in Chrome toolbar
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TestDriver SDK - Act Test (Vitest)
|
|
3
|
-
* Tests the AI exploratory loop (act) functionality
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { describe, expect, it } from "vitest";
|
|
7
|
-
import { TestDriver } from "../../lib/vitest/hooks.mjs";
|
|
8
|
-
|
|
9
|
-
describe("Act Test", () => {
|
|
10
|
-
it("should use act to search for testdriver on Google", async (context) => {
|
|
11
|
-
const testdriver = TestDriver(context, { newSandbox: true });
|
|
12
|
-
|
|
13
|
-
// provision.chrome() automatically calls ready() and starts dashcam
|
|
14
|
-
await testdriver.provision.chrome({
|
|
15
|
-
url: 'https://www.google.com',
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
// Use act to search for testdriver
|
|
19
|
-
let actRes = await testdriver.act("click on the empty search box, type 'testdriver', and hit enter. do not click the plus button in the search bar");
|
|
20
|
-
|
|
21
|
-
console.log("Act response:", actRes);
|
|
22
|
-
|
|
23
|
-
// Assert the search results are displayed
|
|
24
|
-
const result = await testdriver.assert(
|
|
25
|
-
"search results for testdriver are visible",
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
expect(result).toBeTruthy();
|
|
29
|
-
});
|
|
30
|
-
});
|
package/tests/example.test.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { test, expect } from 'vitest';
|
|
2
|
-
import { TestDriver } from 'testdriverai/vitest/hooks';
|
|
3
|
-
import { login } from './login.js';
|
|
4
|
-
|
|
5
|
-
test('should login and add item to cart', async (context) => {
|
|
6
|
-
|
|
7
|
-
// Create TestDriver instance - automatically connects to sandbox
|
|
8
|
-
const testdriver = TestDriver(context);
|
|
9
|
-
|
|
10
|
-
// Launch chrome and navigate to demo app
|
|
11
|
-
await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });
|
|
12
|
-
|
|
13
|
-
// Use the login snippet to handle authentication
|
|
14
|
-
// This demonstrates how to reuse test logic across multiple tests
|
|
15
|
-
await login(testdriver);
|
|
16
|
-
|
|
17
|
-
// Add item to cart
|
|
18
|
-
const addToCartButton = await testdriver.find(
|
|
19
|
-
'add to cart button under TestDriver Hat'
|
|
20
|
-
);
|
|
21
|
-
await addToCartButton.click();
|
|
22
|
-
|
|
23
|
-
// Open cart
|
|
24
|
-
const cartButton = await testdriver.find(
|
|
25
|
-
'cart button in the top right corner'
|
|
26
|
-
);
|
|
27
|
-
await cartButton.click();
|
|
28
|
-
|
|
29
|
-
// Verify item in cart
|
|
30
|
-
const result = await testdriver.assert('TestDriver Hat is in the cart');
|
|
31
|
-
expect(result).toBeTruthy();
|
|
32
|
-
|
|
33
|
-
});
|
package/tests/login.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Login snippet - reusable login function
|
|
3
|
-
*
|
|
4
|
-
* This demonstrates how to create reusable test snippets that can be
|
|
5
|
-
* imported and used across multiple test files.
|
|
6
|
-
*/
|
|
7
|
-
export async function login(testdriver) {
|
|
8
|
-
|
|
9
|
-
// The password is displayed on screen, have TestDriver extract it
|
|
10
|
-
const password = await testdriver.extract('the password');
|
|
11
|
-
|
|
12
|
-
// Find the username field
|
|
13
|
-
const usernameField = await testdriver.find(
|
|
14
|
-
'Username, label above the username input field on the login form'
|
|
15
|
-
);
|
|
16
|
-
await usernameField.click();
|
|
17
|
-
|
|
18
|
-
// Type username
|
|
19
|
-
await testdriver.type('standard_user');
|
|
20
|
-
|
|
21
|
-
// Enter password form earlier
|
|
22
|
-
// Marked as secret so it's not logged or stored
|
|
23
|
-
await testdriver.pressKeys(['tab']);
|
|
24
|
-
await testdriver.type(password, { secret: true });
|
|
25
|
-
|
|
26
|
-
// Submit the form
|
|
27
|
-
await testdriver.find('submit button on the login form').click();
|
|
28
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test case 7: Sort by Enrollments (ascending, numeric)
|
|
3
|
-
*
|
|
4
|
-
* 1. Open page: https://practicetestautomation.com/practice-test-table/
|
|
5
|
-
* 2. Set Sort by = Enrollments
|
|
6
|
-
* 3. Verify visible rows are ordered from smallest to largest enrollment
|
|
7
|
-
* 4. Verify numbers with commas sort correctly
|
|
8
|
-
* 5. Fails if the sort is lexicographic (string-based) instead of numeric
|
|
9
|
-
*
|
|
10
|
-
* EXPECTED: This test should PASS if enrollments are sorted ascending numerically
|
|
11
|
-
* This test should FAIL if sort is lexicographic or descending
|
|
12
|
-
*/
|
|
13
|
-
import { describe, expect, it } from "vitest";
|
|
14
|
-
import { TestDriver } from "../lib/vitest/hooks.mjs";
|
|
15
|
-
|
|
16
|
-
describe("Table Sort - Enrollments", () => {
|
|
17
|
-
|
|
18
|
-
it("should sort enrollments numerically ascending", async (context) => {
|
|
19
|
-
const testdriver = TestDriver(context, {
|
|
20
|
-
newSandbox: true,
|
|
21
|
-
headless: false
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// Step 1: Open the page
|
|
25
|
-
await testdriver.provision.chrome({
|
|
26
|
-
url: 'https://practicetestautomation.com/practice-test-table/',
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// Scroll down to see the Sort by dropdown
|
|
30
|
-
await testdriver.scroll("down");
|
|
31
|
-
await testdriver.scroll("down");
|
|
32
|
-
|
|
33
|
-
// Step 2: Find and click the Sort by dropdown
|
|
34
|
-
const sortDropdown = await testdriver.find("Sort by dropdown", { timeout: 15000 });
|
|
35
|
-
console.log("Sort by dropdown found:", sortDropdown.found());
|
|
36
|
-
expect(sortDropdown.found()).toBeTruthy();
|
|
37
|
-
await sortDropdown.click();
|
|
38
|
-
|
|
39
|
-
// Select "Enrollments" from the dropdown options
|
|
40
|
-
const enrollmentsOption = await testdriver.find("Enrollments option", { timeout: 10000 });
|
|
41
|
-
console.log("Enrollments option found:", enrollmentsOption.found());
|
|
42
|
-
expect(enrollmentsOption.found()).toBeTruthy();
|
|
43
|
-
await enrollmentsOption.click();
|
|
44
|
-
|
|
45
|
-
// Scroll to the TOP of the page to see the first rows of the sorted table
|
|
46
|
-
await testdriver.scroll("up");
|
|
47
|
-
await testdriver.scroll("up");
|
|
48
|
-
await testdriver.scroll("up");
|
|
49
|
-
|
|
50
|
-
// Small wait for sort to complete
|
|
51
|
-
await testdriver.pressKeys([""]); // No-op to add small delay
|
|
52
|
-
|
|
53
|
-
// Scroll down just enough to see the table header and first data rows
|
|
54
|
-
await testdriver.scroll("down");
|
|
55
|
-
|
|
56
|
-
// Step 3: Verify the sort is NUMERIC ASCENDING (smallest to largest)
|
|
57
|
-
// For numeric ascending: 10 < 11 < 50 < 1000 < 1200 < 1365
|
|
58
|
-
// If lexicographic: "1,000" < "10" < "11" < "1,200" < "1365" < "50" (wrong - strings compare char by char)
|
|
59
|
-
//
|
|
60
|
-
// The TEST PASSES if first rows show small numbers like 10, 11, 50
|
|
61
|
-
// The TEST FAILS if first rows show large numbers like 1000, 1200, 1365
|
|
62
|
-
const sortResult = await testdriver.assert(
|
|
63
|
-
"The table is sorted by Enrollments in ASCENDING numeric order. " +
|
|
64
|
-
"The FIRST visible enrollment numbers in the table should be the SMALLEST values. " +
|
|
65
|
-
"For example, if the data contains values like 10, 11, 50, 1000, and 1365, " +
|
|
66
|
-
"then 10 or 11 should appear at the TOP of the sorted table. " +
|
|
67
|
-
"If a large number like 1365 appears first, the sort is WRONG (descending or lexicographic)."
|
|
68
|
-
);
|
|
69
|
-
console.log("Numeric ascending sort assertion result:", sortResult);
|
|
70
|
-
expect(sortResult).toBeTruthy();
|
|
71
|
-
});
|
|
72
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Experiment file - reconnects to existing sandbox
|
|
3
|
-
* Test case 7: Sort by Enrollments (ascending, numeric)
|
|
4
|
-
* Run AFTER table-sort-setup.test.mjs passes (within 2 minutes)
|
|
5
|
-
*/
|
|
6
|
-
import { describe, expect, it } from "vitest";
|
|
7
|
-
import { TestDriver } from "../lib/vitest/hooks.mjs";
|
|
8
|
-
|
|
9
|
-
describe("Table Sort Experiment", () => {
|
|
10
|
-
|
|
11
|
-
it("should sort by Enrollments and verify numeric ordering", async (context) => {
|
|
12
|
-
const testdriver = TestDriver(context, {
|
|
13
|
-
newSandbox: true,
|
|
14
|
-
headless: false,
|
|
15
|
-
reconnect: true // Reconnects to last sandbox
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
// NO provision here! The sandbox is already running from setup.test.mjs
|
|
19
|
-
|
|
20
|
-
// Click on the Sort By dropdown and select Enrollments
|
|
21
|
-
const sortDropdown = await testdriver.find("Sort By dropdown");
|
|
22
|
-
console.log("Sort dropdown found:", sortDropdown.found());
|
|
23
|
-
await sortDropdown.click();
|
|
24
|
-
|
|
25
|
-
// Select Enrollments from the dropdown
|
|
26
|
-
const enrollmentsOption = await testdriver.find("Enrollments option in dropdown");
|
|
27
|
-
console.log("Enrollments option found:", enrollmentsOption.found());
|
|
28
|
-
await enrollmentsOption.click();
|
|
29
|
-
|
|
30
|
-
// Verify the table is now sorted by enrollments (ascending, numeric)
|
|
31
|
-
// The numbers should be ordered from smallest to largest: 10, 11, 50, 1000, 1,200
|
|
32
|
-
// If lexicographic: 1,000, 1,200, 10, 11, 50 (wrong - strings sort by first character)
|
|
33
|
-
const result = await testdriver.assert("The table shows enrollment numbers in ascending numeric order where smaller numbers like 10 or 11 appear before larger numbers like 1000 or 1200");
|
|
34
|
-
console.log("Sort assertion result:", result);
|
|
35
|
-
expect(result).toBeTruthy();
|
|
36
|
-
|
|
37
|
-
// Also verify numbers with commas sort correctly (1,200 should be after 1,000)
|
|
38
|
-
const commaResult = await testdriver.assert("Numbers with commas like 1,000 and 1,200 are sorted correctly as numbers, not as text");
|
|
39
|
-
console.log("Comma sort assertion:", commaResult);
|
|
40
|
-
expect(commaResult).toBeTruthy();
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test case 7: Sort by Enrollments (ascending, numeric)
|
|
3
|
-
*
|
|
4
|
-
* 1. Open page: https://practicetestautomation.com/practice-test-table/
|
|
5
|
-
* 2. Set Sort by = Enrollments
|
|
6
|
-
* 3. Verify visible rows are ordered from smallest to largest enrollment
|
|
7
|
-
* 4. Verify numbers with commas sort correctly
|
|
8
|
-
* 5. Fails if the sort is lexicographic
|
|
9
|
-
*/
|
|
10
|
-
import { describe, expect, it } from "vitest";
|
|
11
|
-
import { TestDriver } from "../lib/vitest/hooks.mjs";
|
|
12
|
-
|
|
13
|
-
describe("Table Sort - Enrollments", () => {
|
|
14
|
-
|
|
15
|
-
it("should sort enrollments numerically ascending", async (context) => {
|
|
16
|
-
const testdriver = TestDriver(context, {
|
|
17
|
-
newSandbox: true,
|
|
18
|
-
headless: false
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
// Step 1: Open the page
|
|
22
|
-
await testdriver.provision.chrome({
|
|
23
|
-
url: 'https://practicetestautomation.com/practice-test-table/',
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// Wait for page to load - find the Sort By dropdown
|
|
27
|
-
const sortDropdown = await testdriver.find("Sort By dropdown or select box", { timeout: 30000 });
|
|
28
|
-
console.log("Sort dropdown found:", sortDropdown.found());
|
|
29
|
-
expect(sortDropdown.found()).toBeTruthy();
|
|
30
|
-
|
|
31
|
-
// Step 2: Click the Sort By dropdown
|
|
32
|
-
await sortDropdown.click();
|
|
33
|
-
|
|
34
|
-
// Select "Enrollments" from the dropdown options
|
|
35
|
-
const enrollmentsOption = await testdriver.find("Enrollments option in the dropdown list", { timeout: 10000 });
|
|
36
|
-
console.log("Enrollments option found:", enrollmentsOption.found());
|
|
37
|
-
await enrollmentsOption.click();
|
|
38
|
-
|
|
39
|
-
// Step 3 & 4: Verify the sort is numeric ascending (not lexicographic)
|
|
40
|
-
// If numeric: smaller numbers (10, 11, 50) come before larger numbers (1000, 1200)
|
|
41
|
-
// If lexicographic: would sort as strings (1,000 before 10 because '1' < '1')
|
|
42
|
-
const sortResult = await testdriver.assert(
|
|
43
|
-
"The table enrollment column is sorted in ascending NUMERIC order: " +
|
|
44
|
-
"smaller enrollment numbers like 10, 11, 50 appear BEFORE larger numbers like 1000 or 1200. " +
|
|
45
|
-
"This is correct numeric sorting, not alphabetical/lexicographic sorting."
|
|
46
|
-
);
|
|
47
|
-
console.log("Numeric sort assertion result:", sortResult);
|
|
48
|
-
expect(sortResult).toBeTruthy();
|
|
49
|
-
|
|
50
|
-
// Step 5: Verify numbers with commas are handled correctly
|
|
51
|
-
// 1,200 should be treated as 1200 (greater than 1000), not as a string
|
|
52
|
-
const commaResult = await testdriver.assert(
|
|
53
|
-
"Any enrollment numbers with commas (like 1,200 or 1,000) are sorted correctly as numbers, " +
|
|
54
|
-
"with 1,000 appearing before 1,200 in ascending order"
|
|
55
|
-
);
|
|
56
|
-
console.log("Comma number sorting result:", commaResult);
|
|
57
|
-
expect(commaResult).toBeTruthy();
|
|
58
|
-
});
|
|
59
|
-
});
|