testdriverai 7.11.264-test → 7.11.266-canary

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 (67) hide show
  1. package/ai/skills/testdriver-quickstart/SKILL.md +1 -1
  2. package/ai/skills/testdriver-quickstart-claude/SKILL.md +47 -10
  3. package/docs/_scripts/generate-skills.js +76 -24
  4. package/docs/quickstart-claude.mdx +47 -10
  5. package/docs/quickstart.mdx +1 -1
  6. package/package.json +2 -2
  7. package/ai/skills/testdriver-ai/SKILL.md +0 -204
  8. package/ai/skills/testdriver-claude-mcp-plugin/SKILL.md +0 -245
  9. package/ai/skills/testdriver-cloud/SKILL.md +0 -119
  10. package/ai/skills/testdriver-device-config/SKILL.md +0 -317
  11. package/ai/skills/testdriver-elements/SKILL.md +0 -605
  12. package/ai/skills/testdriver-examples/SKILL.md +0 -7
  13. package/ai/skills/testdriver-machine-setup/SKILL.md +0 -331
  14. package/ai/skills/testdriver-running-tests/SKILL.md +0 -185
  15. package/ai/skills/testdriver-test-writer/SKILL.md +0 -446
  16. package/ai/skills/testdriver-waiting-for-elements/SKILL.md +0 -90
  17. package/ai/skills/testdriver:ai/SKILL.md +0 -204
  18. package/ai/skills/testdriver:assert/SKILL.md +0 -315
  19. package/ai/skills/testdriver:aws-setup/SKILL.md +0 -448
  20. package/ai/skills/testdriver:cache/SKILL.md +0 -221
  21. package/ai/skills/testdriver:caching/SKILL.md +0 -124
  22. package/ai/skills/testdriver:captcha/SKILL.md +0 -158
  23. package/ai/skills/testdriver:ci-cd/SKILL.md +0 -659
  24. package/ai/skills/testdriver:click/SKILL.md +0 -286
  25. package/ai/skills/testdriver:client/SKILL.md +0 -481
  26. package/ai/skills/testdriver:customizing-devices/SKILL.md +0 -319
  27. package/ai/skills/testdriver:dashcam/SKILL.md +0 -451
  28. package/ai/skills/testdriver:debugging-with-screenshots/SKILL.md +0 -415
  29. package/ai/skills/testdriver:device-config/SKILL.md +0 -317
  30. package/ai/skills/testdriver:double-click/SKILL.md +0 -102
  31. package/ai/skills/testdriver:elements/SKILL.md +0 -605
  32. package/ai/skills/testdriver:enterprise/SKILL.md +0 -7
  33. package/ai/skills/testdriver:errors/SKILL.md +0 -246
  34. package/ai/skills/testdriver:events/SKILL.md +0 -356
  35. package/ai/skills/testdriver:exec/SKILL.md +0 -317
  36. package/ai/skills/testdriver:find/SKILL.md +0 -856
  37. package/ai/skills/testdriver:focus-application/SKILL.md +0 -293
  38. package/ai/skills/testdriver:generating-tests/SKILL.md +0 -25
  39. package/ai/skills/testdriver:hosted/SKILL.md +0 -155
  40. package/ai/skills/testdriver:hover/SKILL.md +0 -278
  41. package/ai/skills/testdriver:locating-elements/SKILL.md +0 -71
  42. package/ai/skills/testdriver:making-assertions/SKILL.md +0 -32
  43. package/ai/skills/testdriver:mcp/SKILL.md +0 -7
  44. package/ai/skills/testdriver:mouse-down/SKILL.md +0 -161
  45. package/ai/skills/testdriver:mouse-up/SKILL.md +0 -164
  46. package/ai/skills/testdriver:parse/SKILL.md +0 -236
  47. package/ai/skills/testdriver:performing-actions/SKILL.md +0 -53
  48. package/ai/skills/testdriver:press-keys/SKILL.md +0 -348
  49. package/ai/skills/testdriver:provision/SKILL.md +0 -331
  50. package/ai/skills/testdriver:quickstart/SKILL.md +0 -172
  51. package/ai/skills/testdriver:redraw/SKILL.md +0 -214
  52. package/ai/skills/testdriver:reusable-code/SKILL.md +0 -249
  53. package/ai/skills/testdriver:right-click/SKILL.md +0 -123
  54. package/ai/skills/testdriver:running-tests/SKILL.md +0 -185
  55. package/ai/skills/testdriver:screenshot/SKILL.md +0 -248
  56. package/ai/skills/testdriver:screenshots/SKILL.md +0 -184
  57. package/ai/skills/testdriver:scroll/SKILL.md +0 -205
  58. package/ai/skills/testdriver:secrets/SKILL.md +0 -115
  59. package/ai/skills/testdriver:self-hosted/SKILL.md +0 -147
  60. package/ai/skills/testdriver:test-results-json/SKILL.md +0 -257
  61. package/ai/skills/testdriver:testdriver/SKILL.md +0 -624
  62. package/ai/skills/testdriver:type/SKILL.md +0 -357
  63. package/ai/skills/testdriver:variables/SKILL.md +0 -111
  64. package/ai/skills/testdriver:wait/SKILL.md +0 -50
  65. package/ai/skills/testdriver:waiting-for-elements/SKILL.md +0 -90
  66. package/ai/skills/testdriver:what-is-testdriver/SKILL.md +0 -54
  67. package/scripts/generate-skills.js +0 -94
@@ -15,7 +15,7 @@ Choose where you want to start:
15
15
  An AI code reviewer that tests every pull request in a real sandbox.
16
16
  </Card>
17
17
  <Card title="Claude Code" icon="terminal" href="/quickstart-claude" arrow horizontal>
18
- Install the plugin to write and run tests from Claude Code.
18
+ Install the connector to write and run tests from Claude Code.
19
19
  </Card>
20
20
  <Card title="VS Code & Cursor" icon="code" href="/quickstart-vscode" arrow horizontal>
21
21
  Install the extension to write tests and watch them run live.
@@ -1,22 +1,59 @@
1
1
  ---
2
2
  name: testdriver:quickstart-claude
3
- description: Install one plugin to get the TestDriver MCP server, agent, and skills in Claude Code.
3
+ description: Install the TestDriver connector from the Claude directory, and Claude Code can drive a live sandbox.
4
4
  ---
5
5
  <!-- Generated from quickstart-claude.mdx. DO NOT EDIT. -->
6
6
 
7
- Install the TestDriver plugin, and Claude Code can write, run, and debug end-to-end tests in a live sandbox.
7
+ Install the TestDriver connector, and Claude Code can write, run, and debug end-to-end tests in a live sandbox.
8
8
 
9
- The plugin bundles three things:
9
+ The connector is the fastest way to get started: one click, a browser sign-in, and no API key to copy. Connectors you install on claude.ai are available automatically in Claude Code, Claude Desktop, and claude.ai chat.
10
10
 
11
- - The TestDriver MCP server
11
+ ## Before you begin
12
+
13
+ - **[Claude Code](https://code.claude.com)**, signed in with the same account you use on claude.ai.
14
+ - **A TestDriver account.** [Sign up at console.testdriver.ai](https://console.testdriver.ai). The free plan includes 30 testing minutes and needs no credit card.
15
+
16
+ <Steps>
17
+ <Step title="Install the connector">
18
+
19
+ Open the TestDriver listing in the Claude directory:
20
+
21
+ [**claude.ai/directory/testdriver**](https://claude.ai/directory/testdriver)
22
+
23
+ Click **Connect**, and sign in to TestDriver when the browser opens.
24
+
25
+ </Step>
26
+ <Step title="Check the connection">
27
+
28
+ Start a Claude Code session and run `/mcp`. The `testdriver` server should be listed as connected.
29
+
30
+ If it isn't, make sure Claude Code is signed in to the same account where you installed the connector, then restart the session.
31
+
32
+ </Step>
33
+ <Step title="Write your first test">
34
+
35
+ Ask Claude Code to drive a browser:
36
+
37
+ ```text
38
+ Use TestDriver to write a test that logs in to https://testdriver-sandbox.vercel.app/login and adds an item to the cart.
39
+ ```
40
+
41
+ Claude starts a sandbox, performs each step, and gets a screenshot after every action. Each tool call also returns the SDK code for that step, which Claude assembles into a runnable [Vitest](https://vitest.dev) test.
42
+
43
+ To save and run those tests locally and in CI, [set up a project](/quickstart-manual).
44
+
45
+ </Step>
46
+ </Steps>
47
+
48
+ ## Alternative: install the plugin
49
+
50
+ Prefer everything to run locally, or want the `testdriver` agent and skills bundled in? Install the TestDriver plugin instead. It bundles three things:
51
+
52
+ - The TestDriver MCP server, run locally over stdio
12
53
  - The `testdriver` agent, which builds tests step by step
13
54
  - Skills that teach Claude the TestDriver SDK
14
55
 
15
- ## Before you begin
16
-
17
- - **[Claude Code](https://code.claude.com)** and **Node.js 20.19 or later**, which runs the MCP server.
18
- - **A TestDriver API key.** Create one at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys).
19
- - **A project with the TestDriver SDK installed**, so the agent can run the tests it writes. If you don't have one yet, see [Set up a project](/quickstart-manual).
56
+ The plugin requires **Node.js 20.19 or later** and a **TestDriver API key**. Create one at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys).
20
57
 
21
58
  <Steps>
22
59
  <Step title="Set your API key">
@@ -63,7 +100,7 @@ The plugin bundles three things:
63
100
  </Steps>
64
101
 
65
102
  <Tip>
66
- Only need TestDriver's tools in chat, without the agent or skills? Add the hosted server instead. It signs in through your browser and needs no API key. See [MCP Setup](/mcp-setup).
103
+ Using another MCP client, or want to add the hosted server by URL instead? See [MCP Setup](/mcp-setup).
67
104
  </Tip>
68
105
 
69
106
  ## Next steps
@@ -4,15 +4,20 @@ const fs = require("fs");
4
4
  const path = require("path");
5
5
 
6
6
  /**
7
- * Script to generate MCP skills from the docs/*.mdx files
7
+ * Script to generate MCP skills from the docs/*.mdx and ai/agents/*.md files
8
8
  *
9
- * This script reads the frontmatter from each mdx file and generates
10
- * SKILL.md files in the skills/ output directory.
9
+ * This script reads the frontmatter from each source file and generates
10
+ * SKILL.md files in the skills/ output directory. Generated skills whose
11
+ * source file no longer exists are pruned; hand-written skills (without
12
+ * the generated marker) are left alone.
11
13
  */
12
14
 
13
15
  const DOCS_DIR = path.join(__dirname, "..");
16
+ const AGENTS_DIR = path.join(__dirname, "../../ai/agents");
14
17
  const OUTPUT_DIR = path.join(__dirname, "../../ai/skills");
15
18
 
19
+ const GENERATED_MARKER = /^<!-- Generated from .* DO NOT EDIT\. -->$/m;
20
+
16
21
  // Parse YAML frontmatter from mdx content
17
22
  function parseFrontmatter(content) {
18
23
  const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
@@ -38,12 +43,12 @@ function parseFrontmatter(content) {
38
43
 
39
44
  // Get skill name from filename (used in SKILL.md frontmatter)
40
45
  function getSkillName(filename) {
41
- return `testdriver:${filename.replace(".mdx", "")}`;
46
+ return `testdriver:${path.basename(filename, path.extname(filename))}`;
42
47
  }
43
48
 
44
49
  // Get directory name from filename (Windows-compatible, uses hyphen instead of colon)
45
50
  function getDirName(filename) {
46
- return `testdriver-${filename.replace(".mdx", "")}`;
51
+ return `testdriver-${path.basename(filename, path.extname(filename))}`;
47
52
  }
48
53
 
49
54
  // Generate SKILL.md content
@@ -61,27 +66,42 @@ ${body}
61
66
  `;
62
67
  }
63
68
 
64
- // Process all mdx files
69
+ // Process all source files
65
70
  function processFiles() {
66
71
  // Ensure output directory exists
67
72
  if (!fs.existsSync(OUTPUT_DIR)) {
68
73
  fs.mkdirSync(OUTPUT_DIR, { recursive: true });
69
74
  }
70
75
 
71
- const files = fs.readdirSync(DOCS_DIR);
72
- const mdxFiles = files.filter(
73
- (file) => file.endsWith(".mdx") && !file.startsWith("_")
74
- );
76
+ const sources = [];
75
77
 
76
- console.log(`Found ${mdxFiles.length} mdx files to process\n`);
78
+ // docs/*.mdx
79
+ for (const file of fs.readdirSync(DOCS_DIR)) {
80
+ if (file.endsWith(".mdx") && !file.startsWith("_")) {
81
+ sources.push({ dir: DOCS_DIR, file });
82
+ }
83
+ }
84
+
85
+ // ai/agents/*.md
86
+ if (fs.existsSync(AGENTS_DIR)) {
87
+ for (const file of fs.readdirSync(AGENTS_DIR)) {
88
+ if (file.endsWith(".md") && !file.startsWith("_")) {
89
+ sources.push({ dir: AGENTS_DIR, file });
90
+ }
91
+ }
92
+ }
93
+
94
+ console.log(`Found ${sources.length} source files to process\n`);
77
95
 
78
96
  let generated = 0;
79
97
  let errors = 0;
98
+ const generatedDirs = new Set();
80
99
 
81
- for (const file of mdxFiles) {
82
- const filePath = path.join(DOCS_DIR, file);
100
+ for (const { dir, file } of sources) {
101
+ const filePath = path.join(dir, file);
83
102
  const skillName = getSkillName(file);
84
- const outputDir = path.join(OUTPUT_DIR, getDirName(file));
103
+ const dirName = getDirName(file);
104
+ const outputDir = path.join(OUTPUT_DIR, dirName);
85
105
  const outputPath = path.join(outputDir, "SKILL.md");
86
106
 
87
107
  try {
@@ -95,6 +115,7 @@ function processFiles() {
95
115
  }
96
116
 
97
117
  fs.writeFileSync(outputPath, skillContent, "utf-8");
118
+ generatedDirs.add(dirName);
98
119
  console.log(`✅ ${skillName}`);
99
120
  generated++;
100
121
  } catch (error) {
@@ -103,19 +124,48 @@ function processFiles() {
103
124
  }
104
125
  }
105
126
 
106
- return { generated, errors };
127
+ const pruned = pruneStaleSkills(generatedDirs);
128
+
129
+ return { generated, errors, pruned };
130
+ }
131
+
132
+ // Remove generated skills whose source file no longer exists.
133
+ // Hand-written skills (without the generated marker) are left alone.
134
+ function pruneStaleSkills(generatedDirs) {
135
+ let pruned = 0;
136
+
137
+ for (const entry of fs.readdirSync(OUTPUT_DIR)) {
138
+ const skillDir = path.join(OUTPUT_DIR, entry);
139
+ if (!fs.lstatSync(skillDir).isDirectory()) continue;
140
+ if (generatedDirs.has(entry)) continue;
141
+
142
+ const skillFile = path.join(skillDir, "SKILL.md");
143
+ if (!fs.existsSync(skillFile)) continue;
144
+
145
+ const content = fs.readFileSync(skillFile, "utf-8");
146
+ if (!GENERATED_MARKER.test(content)) continue;
147
+
148
+ fs.rmSync(skillDir, { recursive: true, force: true });
149
+ console.log(`🗑️ Pruned stale skill: ${entry}`);
150
+ pruned++;
151
+ }
152
+
153
+ return pruned;
107
154
  }
108
155
 
109
156
  // Main function
110
157
  function main() {
111
- console.log("🚀 Generating MCP skills from docs/*.mdx files...\n");
112
- console.log(`📂 Source: ${DOCS_DIR}`);
158
+ console.log("🚀 Generating MCP skills from docs/*.mdx and ai/agents/*.md files...\n");
159
+ console.log(`📂 Sources: ${DOCS_DIR}, ${AGENTS_DIR}`);
113
160
  console.log(`📂 Output: ${OUTPUT_DIR}\n`);
114
161
 
115
- const { generated, errors } = processFiles();
162
+ const { generated, errors, pruned } = processFiles();
116
163
 
117
164
  console.log(`\n✨ Complete!`);
118
165
  console.log(` Generated: ${generated} skills`);
166
+ if (pruned > 0) {
167
+ console.log(` Pruned: ${pruned} stale skills`);
168
+ }
119
169
  if (errors > 0) {
120
170
  console.log(` Errors: ${errors}`);
121
171
  }
@@ -133,14 +183,16 @@ Options:
133
183
  --help, -h Show this help message
134
184
 
135
185
  Description:
136
- This script generates MCP skill files from the docs/*.mdx documentation.
137
-
138
- Each .mdx file is converted to a SKILL.md file with:
186
+ This script generates MCP skill files from the docs/*.mdx documentation
187
+ and the ai/agents/*.md agent definitions.
188
+
189
+ Each source file is converted to a SKILL.md file with:
139
190
  - name: testdriver:<filename>
140
191
  - description: from frontmatter
141
- - Content: the mdx body
142
-
143
- Output is written to the skills/ directory.
192
+ - Content: the source body
193
+
194
+ Output is written to the ai/skills/ directory. Generated skills whose
195
+ source file was removed are pruned; hand-written skills are kept.
144
196
  `);
145
197
  process.exit(0);
146
198
  }
@@ -1,23 +1,60 @@
1
1
  ---
2
2
  title: "Add TestDriver to Claude Code"
3
3
  sidebarTitle: "Claude Code"
4
- description: "Install one plugin to get the TestDriver MCP server, agent, and skills in Claude Code."
4
+ description: "Install the TestDriver connector from the Claude directory, and Claude Code can drive a live sandbox."
5
5
  icon: "terminal"
6
6
  ---
7
7
 
8
- Install the TestDriver plugin, and Claude Code can write, run, and debug end-to-end tests in a live sandbox.
8
+ Install the TestDriver connector, and Claude Code can write, run, and debug end-to-end tests in a live sandbox.
9
9
 
10
- The plugin bundles three things:
10
+ The connector is the fastest way to get started: one click, a browser sign-in, and no API key to copy. Connectors you install on claude.ai are available automatically in Claude Code, Claude Desktop, and claude.ai chat.
11
11
 
12
- - The TestDriver MCP server
12
+ ## Before you begin
13
+
14
+ - **[Claude Code](https://code.claude.com)**, signed in with the same account you use on claude.ai.
15
+ - **A TestDriver account.** [Sign up at console.testdriver.ai](https://console.testdriver.ai). The free plan includes 30 testing minutes and needs no credit card.
16
+
17
+ <Steps>
18
+ <Step title="Install the connector">
19
+
20
+ Open the TestDriver listing in the Claude directory:
21
+
22
+ [**claude.ai/directory/testdriver**](https://claude.ai/directory/testdriver)
23
+
24
+ Click **Connect**, and sign in to TestDriver when the browser opens.
25
+
26
+ </Step>
27
+ <Step title="Check the connection">
28
+
29
+ Start a Claude Code session and run `/mcp`. The `testdriver` server should be listed as connected.
30
+
31
+ If it isn't, make sure Claude Code is signed in to the same account where you installed the connector, then restart the session.
32
+
33
+ </Step>
34
+ <Step title="Write your first test">
35
+
36
+ Ask Claude Code to drive a browser:
37
+
38
+ ```text
39
+ Use TestDriver to write a test that logs in to https://testdriver-sandbox.vercel.app/login and adds an item to the cart.
40
+ ```
41
+
42
+ Claude starts a sandbox, performs each step, and gets a screenshot after every action. Each tool call also returns the SDK code for that step, which Claude assembles into a runnable [Vitest](https://vitest.dev) test.
43
+
44
+ To save and run those tests locally and in CI, [set up a project](/quickstart-manual).
45
+
46
+ </Step>
47
+ </Steps>
48
+
49
+ ## Alternative: install the plugin
50
+
51
+ Prefer everything to run locally, or want the `testdriver` agent and skills bundled in? Install the TestDriver plugin instead. It bundles three things:
52
+
53
+ - The TestDriver MCP server, run locally over stdio
13
54
  - The `testdriver` agent, which builds tests step by step
14
55
  - Skills that teach Claude the TestDriver SDK
15
56
 
16
- ## Before you begin
17
-
18
- - **[Claude Code](https://code.claude.com)** and **Node.js 20.19 or later**, which runs the MCP server.
19
- - **A TestDriver API key.** Create one at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys).
20
- - **A project with the TestDriver SDK installed**, so the agent can run the tests it writes. If you don't have one yet, see [Set up a project](/quickstart-manual).
57
+ The plugin requires **Node.js 20.19 or later** and a **TestDriver API key**. Create one at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys).
21
58
 
22
59
  <Steps>
23
60
  <Step title="Set your API key">
@@ -64,7 +101,7 @@ The plugin bundles three things:
64
101
  </Steps>
65
102
 
66
103
  <Tip>
67
- Only need TestDriver's tools in chat, without the agent or skills? Add the hosted server instead. It signs in through your browser and needs no API key. See [MCP Setup](/mcp-setup).
104
+ Using another MCP client, or want to add the hosted server by URL instead? See [MCP Setup](/mcp-setup).
68
105
  </Tip>
69
106
 
70
107
  ## Next steps
@@ -17,7 +17,7 @@ Choose where you want to start:
17
17
  An AI code reviewer that tests every pull request in a real sandbox.
18
18
  </Card>
19
19
  <Card title="Claude Code" icon="terminal" href="/quickstart-claude" arrow horizontal>
20
- Install the plugin to write and run tests from Claude Code.
20
+ Install the connector to write and run tests from Claude Code.
21
21
  </Card>
22
22
  <Card title="VS Code & Cursor" icon="code" href="/quickstart-vscode" arrow horizontal>
23
23
  Install the extension to write tests and watch them run live.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "7.11.264-test",
3
+ "version": "7.11.266-canary",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "sdk.js",
6
6
  "types": "sdk.d.ts",
@@ -80,7 +80,7 @@
80
80
  "generate-report": "junit-viewer --results=out.xml --save=report.html",
81
81
  "serve-report": "npx http-server . -p 8080 -o report.html",
82
82
  "report": "npm run generate-report && npm run serve-report",
83
- "generate:skills": "node scripts/generate-skills.js",
83
+ "generate:skills": "node docs/_scripts/generate-skills.js",
84
84
  "build:mcp": "cd mcp-server && npm ci && npm run build",
85
85
  "prepublishOnly": "npm run build:mcp"
86
86
  },
@@ -1,204 +0,0 @@
1
- ---
2
- name: testdriver:ai
3
- description: Execute natural language tasks using AI
4
- ---
5
- <!-- Generated from ai.mdx. DO NOT EDIT. -->
6
-
7
- ## Overview
8
-
9
- The `ai()` method allows you to execute complex tasks using natural language descriptions. TestDriver's AI will figure out the steps needed to accomplish the task.
10
-
11
- ## Syntax
12
-
13
- ```javascript
14
- await testdriver.ai(task, options)
15
- ```
16
-
17
- ## Parameters
18
-
19
- <ParamField path="task" type="string" required>
20
- Natural language description of what to do
21
- </ParamField>
22
-
23
- <ParamField path="options" type="object">
24
- Execution options
25
-
26
- <Expandable title="properties">
27
- <ParamField path="validateAndLoop" type="boolean" default="false">
28
- Whether to validate completion and retry if incomplete
29
- </ParamField>
30
- </Expandable>
31
- </ParamField>
32
-
33
- ## Returns
34
-
35
- `Promise<string | void>` - Final AI response if `validateAndLoop` is true
36
-
37
- ## Examples
38
-
39
- ### Basic Usage
40
-
41
- ```javascript
42
- // Simple task execution
43
- await testdriver.ai('Click the submit button');
44
-
45
- // Complex multi-step task
46
- await testdriver.ai('Fill out the contact form and submit it');
47
-
48
- // Navigation task
49
- await testdriver.ai('Go to the settings page and enable notifications');
50
- ```
51
-
52
- ### With Validation
53
-
54
- ```javascript
55
- // AI will verify the task completed successfully
56
- const result = await testdriver.ai('Complete the checkout process', {
57
- validateAndLoop: true
58
- });
59
-
60
- console.log('Task result:', result);
61
- ```
62
-
63
- ### Multi-Step Workflows
64
-
65
- ```javascript
66
- // The AI will break down complex tasks
67
- await testdriver.ai('Search for "laptop", add the first result to cart, and proceed to checkout');
68
-
69
- // UI exploration
70
- await testdriver.ai('Find and click all menu items to explore the application');
71
- ```
72
-
73
- ## Use Cases
74
-
75
- <AccordionGroup>
76
- <Accordion title="Exploratory Testing">
77
- Use AI to explore unfamiliar applications:
78
-
79
- ```javascript
80
- await testdriver.ai('Explore the main navigation menu');
81
- await testdriver.ai('Try to find the user profile settings');
82
- ```
83
- </Accordion>
84
-
85
- <Accordion title="Complex Workflows">
86
- Let AI handle multi-step processes:
87
-
88
- ```javascript
89
- await testdriver.ai('Complete the multi-step registration form');
90
- await testdriver.ai('Configure all the advanced settings to default values');
91
- ```
92
- </Accordion>
93
-
94
- <Accordion title="Flexible Interactions">
95
- When exact element locations aren't critical:
96
-
97
- ```javascript
98
- await testdriver.ai('Close any popup dialogs');
99
- await testdriver.ai('Accept the cookie consent if it appears');
100
- ```
101
- </Accordion>
102
- </AccordionGroup>
103
-
104
- ## Best Practices
105
-
106
- <Check>
107
- **Be specific but flexible**: Give enough context without over-constraining the AI
108
-
109
- ```javascript
110
- // ✅ Good
111
- await testdriver.ai('Add the first product to the shopping cart');
112
-
113
- // ❌ Too vague
114
- await testdriver.ai('do something');
115
-
116
- // ❌ Too specific (defeats the purpose)
117
- await testdriver.ai('click at coordinates 500, 300');
118
- ```
119
- </Check>
120
-
121
- <Check>
122
- **Use for exploration, not precision**: For critical assertions, use explicit methods
123
-
124
- ```javascript
125
- // Use AI for setup
126
- await testdriver.ai('Navigate to the login page');
127
-
128
- // Use explicit methods for critical steps
129
- const usernameField = await testdriver.find('username input');
130
- await usernameField.click();
131
- await testdriver.type('testuser');
132
-
133
- await testdriver.assert('login page is displayed');
134
- ```
135
- </Check>
136
-
137
- <Warning>
138
- **AI tasks may be slower**: The AI needs to analyze the screen and plan actions. For performance-critical tests, use explicit methods.
139
- </Warning>
140
-
141
- ## When to Use AI vs Explicit Methods
142
-
143
- ### Use `ai()` when:
144
- - Exploring unfamiliar applications
145
- - Handling optional UI elements (popups, cookies, etc.)
146
- - Prototyping tests quickly
147
- - Tasks where exact steps may vary
148
-
149
- ### Use explicit methods when:
150
- - Performance is critical
151
- - You need precise control
152
- - Making assertions
153
- - Debugging test failures
154
- - Repetitive, predictable actions
155
-
156
- ## Complete Example
157
-
158
- ```javascript
159
- import { beforeAll, afterAll, describe, it } from 'vitest';
160
- import TestDriver from 'testdriverai';
161
-
162
- describe('E-commerce Flow with AI', () => {
163
- let testdriver;
164
-
165
- beforeAll(async () => {
166
- client = new TestDriver(process.env.TD_API_KEY);
167
- await testdriver.auth();
168
- await testdriver.connect();
169
- });
170
-
171
- afterAll(async () => {
172
- await testdriver.disconnect();
173
- });
174
-
175
- it('should complete shopping flow using AI assistance', async () => {
176
- await testdriver.focusApplication('Google Chrome');
177
-
178
- // Use AI for navigation and exploration
179
- await testdriver.ai('Browse to the electronics section');
180
- await testdriver.ai('Find and add a laptop to the cart');
181
-
182
- // Use explicit methods for critical steps
183
- const cartIcon = await testdriver.find('shopping cart icon');
184
- await cartIcon.click();
185
-
186
- const total = await testdriver.extract('the cart total amount');
187
- console.log('Cart total:', total);
188
-
189
- // Use AI for checkout flow
190
- await testdriver.ai('Proceed to checkout and fill in shipping details', {
191
- validateAndLoop: true
192
- });
193
-
194
- // Explicit assertion
195
- await testdriver.assert('order confirmation page is displayed');
196
- });
197
- });
198
- ```
199
-
200
- ## Related Methods
201
-
202
- - [`find()`](/v7/find) - Locate specific elements
203
- - [`assert()`](/v7/assert) - Make assertions
204
- - [`extract()`](/v7/extract) - Extract information