@testdriverai/agent 7.11.229-test → 7.11.232-test

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.
Files changed (100) hide show
  1. package/docs/_data/examples-manifest.json +16 -16
  2. package/docs/_scripts/generate-examples.js +38 -45
  3. package/docs/agent.mdx +174 -93
  4. package/docs/assert.mdx +73 -269
  5. package/docs/aws-setup.mdx +196 -314
  6. package/docs/bring-your-own-machine.mdx +139 -206
  7. package/docs/cache.mdx +144 -151
  8. package/docs/caching.mdx +99 -89
  9. package/docs/captcha.mdx +126 -111
  10. package/docs/ci-cd.mdx +154 -543
  11. package/docs/click.mdx +74 -229
  12. package/docs/client.mdx +177 -231
  13. package/docs/copilot/auto-healing.mdx +86 -370
  14. package/docs/copilot/running-tests.mdx +121 -930
  15. package/docs/customizing-devices.mdx +74 -251
  16. package/docs/dashcam.mdx +72 -405
  17. package/docs/debugging-with-screenshots.mdx +105 -371
  18. package/docs/docs.json +79 -22
  19. package/docs/double-click.mdx +48 -68
  20. package/docs/errors.mdx +102 -176
  21. package/docs/events.mdx +170 -327
  22. package/docs/examples/{hover-text-with-description.mdx → add-to-cart.mdx} +30 -35
  23. package/docs/examples/assert.mdx +28 -41
  24. package/docs/examples/click-button.mdx +71 -0
  25. package/docs/examples/{hover-image.mdx → click-icon.mdx} +32 -28
  26. package/docs/examples/element-not-found.mdx +27 -26
  27. package/docs/examples/findall-coffee-icons.mdx +28 -32
  28. package/docs/examples/installer.mdx +61 -25
  29. package/docs/examples/launch-vscode-linux.mdx +28 -51
  30. package/docs/examples/navigate-and-scroll.mdx +82 -0
  31. package/docs/examples/parse.mdx +24 -28
  32. package/docs/examples/press-keys.mdx +28 -25
  33. package/docs/examples/scroll.mdx +25 -27
  34. package/docs/examples/type.mdx +26 -21
  35. package/docs/exec.mdx +92 -256
  36. package/docs/extract.mdx +69 -170
  37. package/docs/find.mdx +140 -736
  38. package/docs/focus-application.mdx +69 -246
  39. package/docs/generating-tests.mdx +103 -137
  40. package/docs/guide/best-practices-polling.mdx +65 -141
  41. package/docs/hosted.mdx +80 -144
  42. package/docs/hover.mdx +62 -235
  43. package/docs/locating-elements.mdx +74 -369
  44. package/docs/making-assertions.mdx +116 -74
  45. package/docs/mcp-setup.mdx +80 -63
  46. package/docs/mouse-down.mdx +48 -125
  47. package/docs/mouse-up.mdx +47 -129
  48. package/docs/options.mdx +75 -48
  49. package/docs/parse.mdx +95 -184
  50. package/docs/performing-actions.mdx +104 -94
  51. package/docs/press-keys.mdx +59 -299
  52. package/docs/provision.mdx +137 -182
  53. package/docs/quickstart-claude.mdx +85 -0
  54. package/docs/quickstart-github.mdx +62 -32
  55. package/docs/quickstart-manual.mdx +60 -33
  56. package/docs/quickstart-vscode.mdx +97 -0
  57. package/docs/quickstart.mdx +26 -9
  58. package/docs/redraw.mdx +101 -165
  59. package/docs/reusable-code.mdx +97 -200
  60. package/docs/right-click.mdx +47 -89
  61. package/docs/screenshot.mdx +47 -201
  62. package/docs/screenshots.mdx +87 -137
  63. package/docs/scroll.mdx +71 -154
  64. package/docs/secrets.mdx +96 -91
  65. package/docs/self-hosted.mdx +83 -142
  66. package/docs/snippets/enterprise.mdx +15 -0
  67. package/docs/styles.css +68 -0
  68. package/docs/test-results-json.mdx +167 -204
  69. package/docs/type.mdx +56 -304
  70. package/docs/variables.mdx +121 -81
  71. package/docs/wait.mdx +33 -31
  72. package/docs/what-is-testdriver.mdx +80 -32
  73. package/examples/{hover-text-with-description.test.mjs → add-to-cart.test.mjs} +4 -5
  74. package/examples/assert.test.mjs +3 -20
  75. package/examples/{hover-text.test.mjs → click-button.test.mjs} +3 -4
  76. package/examples/{hover-image.test.mjs → click-icon.test.mjs} +5 -6
  77. package/examples/element-not-found.test.mjs +3 -5
  78. package/examples/findall-coffee-icons.test.mjs +3 -3
  79. package/examples/installer.test.mjs +1 -1
  80. package/examples/launch-vscode-linux.test.mjs +6 -33
  81. package/examples/{scroll-keyboard.test.mjs → navigate-and-scroll.test.mjs} +4 -5
  82. package/examples/parse.test.mjs +1 -2
  83. package/examples/press-keys.test.mjs +4 -4
  84. package/examples/scroll.test.mjs +3 -6
  85. package/examples/type.test.mjs +5 -2
  86. package/lib/provision.js +6 -2
  87. package/package.json +1 -1
  88. package/sdk.d.ts +4 -2
  89. package/sdk.js +1 -1
  90. package/docs/claude-mcp-plugin.mdx +0 -244
  91. package/docs/elements.mdx +0 -606
  92. package/docs/examples/ai.mdx +0 -78
  93. package/docs/examples/captcha-api.mdx +0 -92
  94. package/docs/examples/chrome-extension.mdx +0 -156
  95. package/docs/examples/drag-and-drop.mdx +0 -100
  96. package/docs/examples/formatted-logging.mdx +0 -74
  97. package/docs/examples/hover-text.mdx +0 -70
  98. package/docs/examples/match-image.mdx +0 -97
  99. package/docs/examples/scroll-keyboard.mdx +0 -80
  100. package/docs/examples/scroll-until-text.mdx +0 -109
@@ -1,14 +1,14 @@
1
1
  ---
2
- title: "Launching VS Code Test Example"
2
+ title: "Launch VS Code"
3
3
  sidebarTitle: "Launch VS Code"
4
- description: "Example test demonstrating how to launch VS Code and install extensions on Linux."
5
- icon: "play"
4
+ description: "Launch VS Code in a Linux sandbox and check that its window opens."
5
+ icon: "code"
6
6
  mode: "wide"
7
7
  ---
8
8
 
9
- ## Demo Test Run
9
+ This test launches VS Code with `provision.vscode()` and waits for its window to appear.
10
10
 
11
- Watch this test execute in a real sandbox environment:
11
+ ## Watch it run
12
12
 
13
13
  {/* launch-vscode-linux.test.mjs output */}
14
14
  <iframe
@@ -19,9 +19,9 @@ Watch this test execute in a real sandbox environment:
19
19
  allow="fullscreen"
20
20
  />
21
21
 
22
- ## Source Code
22
+ ## The test
23
23
 
24
- ```javascript title="launch-vscode-linux.test.mjs" {13,27-29}
24
+ ```javascript title="launch-vscode-linux.test.mjs"
25
25
  import { describe, expect, it } from "vitest";
26
26
  import { TestDriver } from "testdriverai/vitest/hooks";
27
27
 
@@ -31,12 +31,11 @@ describe("Launch VS Code on Linux", () => {
31
31
  it.skipIf(!isLinux)(
32
32
  "should launch VS Code on Debian/Ubuntu",
33
33
  async (context) => {
34
- const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP});
35
-
36
- // provision.vscode() automatically calls ready() and starts dashcam
34
+ const testdriver = TestDriver(context);
35
+
37
36
  await testdriver.provision.vscode();
38
37
 
39
- // Wait for VS Code to launch (polls every 5s until found or timeout)
38
+ // Poll for up to 60 seconds while VS Code starts
40
39
  const vsCodeWindow = await testdriver.find(
41
40
  "Visual Studio Code window",
42
41
  { timeout: 60000 }
@@ -45,53 +44,31 @@ describe("Launch VS Code on Linux", () => {
45
44
  },
46
45
  );
47
46
 
48
- // it.skipIf(!isLinux)(
49
- // "should install and use a VS Code extension",
50
- // async (context) => {
51
- // const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP});
52
-
53
- // // Launch VS Code with the Prettier extension installed
54
- // await testdriver.provision.vscode({
55
- // extensions: ["esbenp.prettier-vscode"],
56
- // });
57
-
58
- // const vsCodeWindow = await testdriver.find(
59
- // "Visual Studio Code window",
60
- // { timeout: 60000 }
61
- // );
62
-
63
- // expect(vsCodeWindow.found()).toBeTruthy();
64
-
65
- // // Open the extensions panel to verify Prettier is installed
66
- // await testdriver.pressKeys(["ctrl", "shift", "x"]);
67
-
68
- // // Wait for extensions panel to open
69
- // await new Promise((resolve) => setTimeout(resolve, 2000));
70
-
71
- // // Assert that Prettier extension is visible in the installed extensions
72
- // const prettierVisible = await testdriver.assert(
73
- // "Prettier extension is visible in the extensions panel or sidebar",
74
- // );
75
- // expect(prettierVisible).toBeTruthy();
76
- // },
77
- // );
78
47
  });
79
48
  ```
80
49
 
81
- ## Running This Example
50
+ ## How it works
51
+
52
+ - `provision.vscode()` starts VS Code in the sandbox.
53
+ - `timeout: 60000` makes `find()` keep checking for up to 60 seconds. This gives VS Code time to start.
54
+ - `found()` returns `true` once the window is on screen.
55
+ - `it.skipIf(!isLinux)` skips the test when `TD_OS` is set to `windows`.
56
+
57
+ ## Run it
58
+
59
+ The test is in the [TestDriver SDK repository](https://github.com/testdriverai/testdriverai/tree/main/examples). Clone it, install dependencies, and run the file:
82
60
 
83
61
  ```bash
84
- # Clone the TestDriver repository
85
62
  git clone https://github.com/testdriverai/testdriverai
86
-
87
- # Install dependencies
88
63
  cd testdriverai
89
64
  npm install
90
-
91
- # Run this specific example
92
- vitest run examples/launch-vscode-linux.test.mjs
65
+ npx vitest run examples/launch-vscode-linux.test.mjs
93
66
  ```
94
67
 
95
- <Note>
96
- Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
97
- </Note>
68
+ The test reads your API key from `TD_API_KEY`. Create a key at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys). Then set it in your environment or a `.env` file.
69
+
70
+ ## Related
71
+
72
+ - [Provision apps](/provision)
73
+ - [find()](/find)
74
+ - [Waiting for elements](/guide/best-practices-polling)
@@ -0,0 +1,82 @@
1
+ ---
2
+ title: "Navigate with the address bar and scroll"
3
+ sidebarTitle: "Address bar and scroll"
4
+ description: "Navigate by typing in Chrome's address bar, then scroll and assert on the result."
5
+ icon: "scroll"
6
+ mode: "wide"
7
+ ---
8
+
9
+ This test types a URL into Chrome's address bar, scrolls down, and asserts that the heading is out of view.
10
+
11
+ ## Watch it run
12
+
13
+ {/* navigate-and-scroll.test.mjs output */}
14
+ <iframe
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6ad6b600022b6043aeec2bf0/replay"
16
+ width="100%"
17
+ height="390"
18
+ style={{ border: "1px solid #333", borderRadius: "8px" }}
19
+ allow="fullscreen"
20
+ />
21
+
22
+ ## The test
23
+
24
+ ```javascript title="navigate-and-scroll.test.mjs"
25
+ import { describe, expect, it } from "vitest";
26
+ import { TestDriver } from "testdriverai/vitest/hooks";
27
+
28
+ describe("Scroll Keyboard Test", () => {
29
+ it("should navigate to webhamster.com and scroll with keyboard", async (context) => {
30
+ const testdriver = TestDriver(context);
31
+ await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });
32
+
33
+ // Navigate to https://www.webhamster.com/ through the address bar
34
+ await testdriver.focusApplication("Google Chrome");
35
+ const urlBar = await testdriver.find(
36
+ "the URL in the omnibox", {zoom: true}
37
+ );
38
+ await urlBar.click();
39
+ await testdriver.pressKeys(["ctrl", "a"]);
40
+ await testdriver.type("https://www.webhamster.com/");
41
+ await testdriver.pressKeys(["enter"]);
42
+
43
+ // Click the page so it has focus, then scroll down
44
+ const heading = await testdriver.find(
45
+ "The Hamster Dance, large heading at top of page",
46
+ );
47
+ await heading.click();
48
+ await testdriver.scroll("down", { amount: 1000 });
49
+
50
+ // Assert the page is scrolled down
51
+ const result = await testdriver.assert("The text 'The Hamster Dance' is not visible on the webpage content. It's ok if it's visible in the tab title.");
52
+
53
+ expect(result).toBeTruthy();
54
+ });
55
+ });
56
+ ```
57
+
58
+ ## How it works
59
+
60
+ - `find()` with `zoom: true` locates the element in two passes for extra precision. This helps with small targets like the address bar.
61
+ - `pressKeys(['ctrl', 'a'])` selects the current URL so `type()` replaces it.
62
+ - The test clicks the page before scrolling so the page, not the address bar, gets the scroll.
63
+ - `scroll('down', { amount: 1000 })` scrolls down with the mouse wheel.
64
+
65
+ ## Run it
66
+
67
+ The test is in the [TestDriver SDK repository](https://github.com/testdriverai/testdriverai/tree/main/examples). Clone it, install dependencies, and run the file:
68
+
69
+ ```bash
70
+ git clone https://github.com/testdriverai/testdriverai
71
+ cd testdriverai
72
+ npm install
73
+ npx vitest run examples/navigate-and-scroll.test.mjs
74
+ ```
75
+
76
+ The test reads your API key from `TD_API_KEY`. Create a key at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys). Then set it in your environment or a `.env` file.
77
+
78
+ ## Related
79
+
80
+ - [scroll()](/scroll)
81
+ - [find()](/find)
82
+ - [focusApplication()](/focus-application)
@@ -1,20 +1,14 @@
1
1
  ---
2
- title: "Parse Test Example"
2
+ title: "List the elements on screen"
3
3
  sidebarTitle: "Parse"
4
- description: "TestDriver SDK - Parse Test (Vitest) Opens Airbnb and runs the .parse() SDK command to analyze the screen."
5
- icon: "play"
4
+ description: "Open a website and use parse() to list the UI elements on screen."
5
+ icon: "table-list"
6
6
  mode: "wide"
7
7
  ---
8
8
 
9
- ## Overview
9
+ This test opens Airbnb in Chrome and calls `parse()` to detect every UI element on screen.
10
10
 
11
- TestDriver SDK - Parse Test (Vitest) Opens Airbnb and runs the .parse() SDK command to analyze the screen.
12
-
13
- Review the source code below to understand the implementation details and patterns used.
14
-
15
- ## Live Test Run
16
-
17
- Watch this test execute in a real sandbox environment:
11
+ ## Watch it run
18
12
 
19
13
  {/* parse.test.mjs output */}
20
14
  <iframe
@@ -25,20 +19,15 @@ Watch this test execute in a real sandbox environment:
25
19
  allow="fullscreen"
26
20
  />
27
21
 
28
- ## Source Code
22
+ ## The test
29
23
 
30
24
  ```javascript title="parse.test.mjs"
31
- /**
32
- * TestDriver SDK - Parse Test (Vitest)
33
- * Opens Airbnb and runs the .parse() SDK command to analyze the screen.
34
- */
35
-
36
25
  import { describe, it } from "vitest";
37
26
  import { TestDriver } from "testdriverai/vitest/hooks";
38
27
 
39
28
  describe("Parse Test", () => {
40
29
  it("should open Airbnb and parse the screen", async (context) => {
41
- const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP});
30
+ const testdriver = TestDriver(context);
42
31
  await testdriver.provision.chrome({ url: "https://www.airbnb.com" });
43
32
 
44
33
  // The SDK automatically outputs elements as a formatted table
@@ -48,20 +37,27 @@ describe("Parse Test", () => {
48
37
  });
49
38
  ```
50
39
 
51
- ## Running This Example
40
+ ## How it works
41
+
42
+ - `parse()` analyzes the screen and resolves to an object. Its `elements` array lists each detected element.
43
+ - The result also has `annotatedImageUrl`, a screenshot with the elements marked.
44
+ - It also has `imageWidth` and `imageHeight`.
45
+ - Use parsing to explore an unfamiliar screen before you write `find()` descriptions.
46
+
47
+ ## Run it
48
+
49
+ The test is in the [TestDriver SDK repository](https://github.com/testdriverai/testdriverai/tree/main/examples). Clone it, install dependencies, and run the file:
52
50
 
53
51
  ```bash
54
- # Clone the TestDriver repository
55
52
  git clone https://github.com/testdriverai/testdriverai
56
-
57
- # Install dependencies
58
53
  cd testdriverai
59
54
  npm install
60
-
61
- # Run this specific example
62
- vitest run examples/parse.test.mjs
55
+ npx vitest run examples/parse.test.mjs
63
56
  ```
64
57
 
65
- <Note>
66
- Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
67
- </Note>
58
+ The test reads your API key from `TD_API_KEY`. Create a key at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys). Then set it in your environment or a `.env` file.
59
+
60
+ ## Related
61
+
62
+ - [parse()](/parse)
63
+ - [Locate elements](/locating-elements)
@@ -1,14 +1,14 @@
1
1
  ---
2
- title: "Pressing Keys Test Example"
3
- sidebarTitle: "Pressing Keys"
4
- description: "Example test demonstrating keyboard shortcuts and key combinations for browser navigation."
2
+ title: "Use keyboard shortcuts"
3
+ sidebarTitle: "Press keys"
4
+ description: "Use pressKeys() to open a tab, open DevTools, and navigate in Chrome."
5
5
  icon: "keyboard"
6
6
  mode: "wide"
7
7
  ---
8
8
 
9
- ## Demo Test Run
9
+ This test drives Chrome with keyboard shortcuts to open tabs and DevTools, then types a URL.
10
10
 
11
- Watch this test execute in a real sandbox environment:
11
+ ## Watch it run
12
12
 
13
13
  {/* press-keys.test.mjs output */}
14
14
  <iframe
@@ -19,20 +19,15 @@ Watch this test execute in a real sandbox environment:
19
19
  allow="fullscreen"
20
20
  />
21
21
 
22
- ## Source Code
23
-
24
- ```javascript title="press-keys.test.mjs" {17,24,36}
25
- /**
26
- * TestDriver SDK - Press Keys Test (Vitest)
27
- * Converted from: testdriver/acceptance/press-keys.yaml
28
- */
22
+ ## The test
29
23
 
24
+ ```javascript title="press-keys.test.mjs"
30
25
  import { describe, expect, it } from "vitest";
31
26
  import { TestDriver } from "testdriverai/vitest/hooks";
32
27
 
33
28
  describe("Press Keys Test", () => {
34
29
  it("should create tabs and navigate using keyboard shortcuts", async (context) => {
35
- const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP, headless: true });
30
+ const testdriver = TestDriver(context);
36
31
  await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });
37
32
 
38
33
  const signInButton = await testdriver.find(
@@ -43,7 +38,7 @@ describe("Press Keys Test", () => {
43
38
  // Open new tab
44
39
  await testdriver.pressKeys(["ctrl", "t"]);
45
40
 
46
- // Poll for "Learn more" to appear
41
+ // Wait for the new tab page to load
47
42
  let imagesLink = await testdriver.find("Images", {timeout: 5000});
48
43
 
49
44
  expect(imagesLink.found()).toBeTruthy();
@@ -51,7 +46,7 @@ describe("Press Keys Test", () => {
51
46
  // Open DevTools
52
47
  await testdriver.pressKeys(["ctrl", "shift", "i"]);
53
48
 
54
- // Poll for "Elements" to appear
49
+ // Wait for the DevTools Elements panel
55
50
  let elements = await testdriver.find("Elements", {timeout: 5000});
56
51
  expect(elements.found()).toBeTruthy();
57
52
 
@@ -67,20 +62,28 @@ describe("Press Keys Test", () => {
67
62
  });
68
63
  ```
69
64
 
70
- ## Running This Example
65
+ ## How it works
66
+
67
+ - `pressKeys()` presses an array of keys together.
68
+ - `['ctrl', 't']` opens a new tab, and `['ctrl', 'shift', 'i']` opens DevTools.
69
+ - After each shortcut, `find()` with a short `timeout` waits for what the shortcut should reveal. This confirms the shortcut worked.
70
+ - `type()` types into the focused element, here the new tab's address bar.
71
+
72
+ ## Run it
73
+
74
+ The test is in the [TestDriver SDK repository](https://github.com/testdriverai/testdriverai/tree/main/examples). Clone it, install dependencies, and run the file:
71
75
 
72
76
  ```bash
73
- # Clone the TestDriver repository
74
77
  git clone https://github.com/testdriverai/testdriverai
75
-
76
- # Install dependencies
77
78
  cd testdriverai
78
79
  npm install
79
-
80
- # Run this specific example
81
- vitest run examples/press-keys.test.mjs
80
+ npx vitest run examples/press-keys.test.mjs
82
81
  ```
83
82
 
84
- <Note>
85
- Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
86
- </Note>
83
+ The test reads your API key from `TD_API_KEY`. Create a key at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys). Then set it in your environment or a `.env` file.
84
+
85
+ ## Related
86
+
87
+ - [pressKeys()](/press-keys)
88
+ - [type()](/type)
89
+ - [find()](/find)
@@ -1,14 +1,14 @@
1
1
  ---
2
- title: "Scrolling Test Example"
3
- sidebarTitle: "Scrolling"
4
- description: "Example test demonstrating page scrolling with configurable direction and scroll amount."
2
+ title: "Scroll a page"
3
+ sidebarTitle: "Scroll"
4
+ description: "Scroll a page down and assert that its heading has scrolled out of view."
5
5
  icon: "scroll"
6
6
  mode: "wide"
7
7
  ---
8
8
 
9
- ## Demo Test Run
9
+ This test opens a page, scrolls down, and asserts that the page heading is no longer visible.
10
10
 
11
- Watch this test execute in a real sandbox environment:
11
+ ## Watch it run
12
12
 
13
13
  {/* scroll.test.mjs output */}
14
14
  <iframe
@@ -19,26 +19,18 @@ Watch this test execute in a real sandbox environment:
19
19
  allow="fullscreen"
20
20
  />
21
21
 
22
- ## Source Code
23
-
24
- ```javascript title="scroll.test.mjs" {29}
25
- /**
26
- * TestDriver SDK - Scroll Test (Vitest)
27
- * Converted from: testdriver/acceptance/scroll.yaml
28
- *
29
- * UPDATED: Now using chrome preset for automatic setup
30
- */
22
+ ## The test
31
23
 
24
+ ```javascript title="scroll.test.mjs"
32
25
  import { describe, expect, it } from "vitest";
33
26
  import { TestDriver } from "testdriverai/vitest/hooks";
34
27
 
35
28
  describe("Scroll Test", () => {
36
29
  it("should navigate and scroll down the page", async (context) => {
37
- const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP, headless: true });
30
+ const testdriver = TestDriver(context);
38
31
  await testdriver.provision.chrome({ url: 'https://www.webhamster.com/' });
39
32
 
40
-
41
- // Wait for page to load and click heading
33
+ // Click the page so it has focus before scrolling
42
34
  const heading = await testdriver.find(
43
35
  "The Hamster Dance, large heading at top of page",
44
36
  );
@@ -54,20 +46,26 @@ describe("Scroll Test", () => {
54
46
  });
55
47
  ```
56
48
 
57
- ## Running This Example
49
+ ## How it works
50
+
51
+ - The test clicks the heading first so the page has focus and gets the scroll.
52
+ - `scroll('down', { amount: 1000 })` scrolls down with the mouse wheel. The default amount is 300.
53
+ - The assertion adds an exception ("It's ok if it's visible in the tab title"). This stops the AI from counting the tab title as the heading.
54
+
55
+ ## Run it
56
+
57
+ The test is in the [TestDriver SDK repository](https://github.com/testdriverai/testdriverai/tree/main/examples). Clone it, install dependencies, and run the file:
58
58
 
59
59
  ```bash
60
- # Clone the TestDriver repository
61
60
  git clone https://github.com/testdriverai/testdriverai
62
-
63
- # Install dependencies
64
61
  cd testdriverai
65
62
  npm install
66
-
67
- # Run this specific example
68
- vitest run examples/scroll.test.mjs
63
+ npx vitest run examples/scroll.test.mjs
69
64
  ```
70
65
 
71
- <Note>
72
- Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
73
- </Note>
66
+ The test reads your API key from `TD_API_KEY`. Create a key at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys). Then set it in your environment or a `.env` file.
67
+
68
+ ## Related
69
+
70
+ - [scroll()](/scroll)
71
+ - [assert()](/assert)
@@ -1,14 +1,14 @@
1
1
  ---
2
- title: "Typing Test Example"
3
- sidebarTitle: "Typing"
4
- description: "Example test demonstrating how to type text into input fields and verify the content."
2
+ title: "Type into a form"
3
+ sidebarTitle: "Type"
4
+ description: "Type into a login form and assert on the validation message for a missing password."
5
5
  icon: "keyboard"
6
6
  mode: "wide"
7
7
  ---
8
8
 
9
- ## Demo Test Run
9
+ This file has two login form tests. One types a username and checks the field. The other submits without a password and checks the browser's validation message.
10
10
 
11
- Watch this test execute in a real sandbox environment:
11
+ ## Watch it run
12
12
 
13
13
  {/* type.test.mjs output */}
14
14
  <iframe
@@ -19,18 +19,17 @@ Watch this test execute in a real sandbox environment:
19
19
  allow="fullscreen"
20
20
  />
21
21
 
22
- ## Source Code
22
+ ## The test
23
23
 
24
- ```javascript title="type.test.mjs" {13}
24
+ ```javascript title="type.test.mjs"
25
25
  import { describe, expect, it } from "vitest";
26
26
  import { TestDriver } from "testdriverai/vitest/hooks";
27
27
 
28
28
  describe("Type Test", () => {
29
29
  it("should enter standard_user in username field", async (context) => {
30
- const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP, headless: true });
30
+ const testdriver = TestDriver(context);
31
31
  await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });
32
32
 
33
- //
34
33
  const usernameField = await testdriver.find(
35
34
  "Username, input field for username",
36
35
  );
@@ -44,7 +43,7 @@ describe("Type Test", () => {
44
43
  });
45
44
 
46
45
  it("should show validation message when clicking Sign In without password", async (context) => {
47
- const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP, headless: true });
46
+ const testdriver = TestDriver(context);
48
47
  await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });
49
48
 
50
49
  // First fill in username
@@ -54,7 +53,6 @@ describe("Type Test", () => {
54
53
  await usernameField.click();
55
54
  await testdriver.type("standard_user");
56
55
 
57
- //
58
56
  const signInButton = await testdriver.find(
59
57
  "Sign in, black button below the password field",
60
58
  );
@@ -69,20 +67,27 @@ describe("Type Test", () => {
69
67
  });
70
68
  ```
71
69
 
72
- ## Running This Example
70
+ ## How it works
71
+
72
+ - `type()` types into the focused element, so each test clicks the username field first.
73
+ - `assert()` can check a field's contents (`the username field contains "standard_user"`) as well as on-screen messages.
74
+ - The second test calls `focusApplication('Google Chrome')` before asserting. This keeps Chrome in front when the validation tooltip appears.
75
+
76
+ ## Run it
77
+
78
+ The test is in the [TestDriver SDK repository](https://github.com/testdriverai/testdriverai/tree/main/examples). Clone it, install dependencies, and run the file:
73
79
 
74
80
  ```bash
75
- # Clone the TestDriver repository
76
81
  git clone https://github.com/testdriverai/testdriverai
77
-
78
- # Install dependencies
79
82
  cd testdriverai
80
83
  npm install
81
-
82
- # Run this specific example
83
- vitest run examples/type.test.mjs
84
+ npx vitest run examples/type.test.mjs
84
85
  ```
85
86
 
86
- <Note>
87
- Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
88
- </Note>
87
+ The test reads your API key from `TD_API_KEY`. Create a key at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys). Then set it in your environment or a `.env` file.
88
+
89
+ ## Related
90
+
91
+ - [type()](/type)
92
+ - [click()](/click)
93
+ - [assert()](/assert)