testdriverai 7.2.12 → 7.2.14

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.
@@ -0,0 +1,70 @@
1
+ name: Scheduled Acceptance Tests (Linux)
2
+
3
+ permissions:
4
+ id-token: write
5
+ contents: read
6
+
7
+ on:
8
+ schedule:
9
+ # Every 6 hours
10
+ - cron: '0 */6 * * *'
11
+ workflow_dispatch: # Allow manual trigger
12
+
13
+ jobs:
14
+ test-linux:
15
+ runs-on: ubuntu-latest
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Setup Node.js
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version: '20'
24
+ cache: 'npm'
25
+
26
+ - name: Install dependencies
27
+ run: npm ci
28
+
29
+ - name: Install Sentry CLI
30
+ run: npm install -g @sentry/cli
31
+
32
+ - name: Sentry Cron Check-in (Start)
33
+ env:
34
+ SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
35
+ SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
36
+ SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
37
+ run: |
38
+ CHECK_IN_ID=$(sentry-cli monitors checkin testdriver-linux-acceptance --status in_progress 2>&1 | grep -oE '[a-f0-9-]{36}' | head -1)
39
+ echo "CHECK_IN_ID=$CHECK_IN_ID" >> $GITHUB_ENV
40
+
41
+ - name: Run Linux tests
42
+ id: tests
43
+ run: npx vitest run test/testdriver/*.test.mjs
44
+ env:
45
+ TD_API_KEY: ${{ secrets.TD_API_KEY }}
46
+ TD_OS: linux
47
+
48
+ - name: Sentry Cron Check-in (Success)
49
+ if: success()
50
+ env:
51
+ SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
52
+ SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
53
+ SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
54
+ run: |
55
+ sentry-cli monitors checkin testdriver-linux-acceptance --check-in-id ${{ env.CHECK_IN_ID }} --status ok
56
+
57
+ - name: Sentry Cron Check-in (Failure)
58
+ if: failure()
59
+ env:
60
+ SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
61
+ SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
62
+ SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
63
+ run: |
64
+ sentry-cli monitors checkin testdriver-linux-acceptance --check-in-id ${{ env.CHECK_IN_ID }} --status error
65
+
66
+ - name: Upload test results to Sentry Prevent
67
+ if: ${{ !cancelled() }}
68
+ uses: getsentry/prevent-action@v0
69
+ with:
70
+ token: ${{ secrets.SENTRY_PREVENT_TOKEN }}
@@ -0,0 +1,70 @@
1
+ name: Scheduled Acceptance Tests (Windows)
2
+
3
+ permissions:
4
+ id-token: write
5
+ contents: read
6
+
7
+ on:
8
+ schedule:
9
+ # Every day at midnight UTC
10
+ - cron: '0 0 * * *'
11
+ workflow_dispatch: # Allow manual trigger
12
+
13
+ jobs:
14
+ test-windows:
15
+ runs-on: ubuntu-latest
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Setup Node.js
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version: '20'
24
+ cache: 'npm'
25
+
26
+ - name: Install dependencies
27
+ run: npm ci
28
+
29
+ - name: Install Sentry CLI
30
+ run: npm install -g @sentry/cli
31
+
32
+ - name: Sentry Cron Check-in (Start)
33
+ env:
34
+ SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
35
+ SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
36
+ SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
37
+ run: |
38
+ CHECK_IN_ID=$(sentry-cli monitors checkin testdriver-windows-acceptance --status in_progress 2>&1 | grep -oE '[a-f0-9-]{36}' | head -1)
39
+ echo "CHECK_IN_ID=$CHECK_IN_ID" >> $GITHUB_ENV
40
+
41
+ - name: Run Windows tests
42
+ id: tests
43
+ run: npx vitest run test/testdriver/*.test.mjs
44
+ env:
45
+ TD_API_KEY: ${{ secrets.TD_API_KEY }}
46
+ TD_OS: windows
47
+
48
+ - name: Sentry Cron Check-in (Success)
49
+ if: success()
50
+ env:
51
+ SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
52
+ SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
53
+ SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
54
+ run: |
55
+ sentry-cli monitors checkin testdriver-windows-acceptance --check-in-id ${{ env.CHECK_IN_ID }} --status ok
56
+
57
+ - name: Sentry Cron Check-in (Failure)
58
+ if: failure()
59
+ env:
60
+ SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
61
+ SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
62
+ SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
63
+ run: |
64
+ sentry-cli monitors checkin testdriver-windows-acceptance --check-in-id ${{ env.CHECK_IN_ID }} --status error
65
+
66
+ - name: Upload test results to Sentry Prevent
67
+ if: ${{ !cancelled() }}
68
+ uses: getsentry/prevent-action@v0
69
+ with:
70
+ token: ${{ secrets.SENTRY_PREVENT_TOKEN }}
@@ -37,6 +37,8 @@ jobs:
37
37
  - name: Upload test results to Sentry Prevent
38
38
  if: ${{ !cancelled() }}
39
39
  uses: getsentry/prevent-action@v0
40
+ with:
41
+ token: ${{ secrets.SENTRY_PREVENT_TOKEN }}
40
42
 
41
43
  - name: Publish Test Results
42
44
  uses: EnricoMi/publish-unit-test-result-action@v2
@@ -1,7 +1,7 @@
1
1
  {
2
- "sandboxId": "i-034317335b2eb9678",
3
- "os": "windows",
2
+ "sandboxId": "i4kn8zrl6y0483ooe10pl",
3
+ "os": "linux",
4
4
  "ami": null,
5
5
  "instanceType": null,
6
- "timestamp": "2025-12-22T23:09:20.319Z"
6
+ "timestamp": "2026-01-06T19:39:48.956Z"
7
7
  }
@@ -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;
@@ -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 text (for backward compatibility)
723
- * @param {string} options.text - Text to find and hover over
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 text, description, action, timeout;
728
+ let description, action, timeout;
730
729
 
731
730
  // Handle both object and positional argument styles
732
- if (isObjectArgs(args, ['text', 'description', 'action', 'timeout'])) {
733
- ({ text, description = null, action = 'click', timeout = 5000 } = args[0]);
731
+ if (isObjectArgs(args, ['description', 'action', 'timeout'])) {
732
+ ({ description, action = 'click', timeout = 5000 } = args[0]);
734
733
  } else {
735
- // Legacy positional: hoverText(text, description, action, timeout)
736
- [text, description = null, action = 'click', timeout = 5000] = args;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "7.2.12",
3
+ "version": "7.2.14",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "sdk.js",
6
6
  "exports": {
@@ -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 testdriver.ai website is visible");
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
- });
@@ -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
- });