testdriverai 7.8.0-test.7 → 7.8.0-test.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent/index.js +18 -5
- package/agent/lib/commands.js +3 -2
- package/agent/lib/http.js +162 -0
- package/agent/lib/logger.js +15 -0
- package/agent/lib/sandbox.js +554 -209
- package/agent/lib/sdk.js +5 -22
- package/agent/lib/system.js +25 -65
- package/ai/skills/testdriver-cache/SKILL.md +221 -0
- package/ai/skills/testdriver-errors/SKILL.md +246 -0
- package/ai/skills/testdriver-events/SKILL.md +356 -0
- package/ai/skills/testdriver-find/SKILL.md +14 -20
- package/ai/skills/testdriver-mcp/SKILL.md +7 -0
- package/ai/skills/testdriver-provision/SKILL.md +331 -0
- package/ai/skills/testdriver-redraw/SKILL.md +214 -0
- package/ai/skills/testdriver-running-tests/SKILL.md +1 -1
- package/ai/skills/testdriver-screenshots/SKILL.md +184 -0
- package/docs/_data/examples-manifest.json +46 -46
- package/docs/_scripts/extract-example-urls.js +67 -72
- package/docs/changelog.mdx +148 -8
- package/docs/docs.json +46 -38
- package/docs/images/content/vscode/v7-chat.png +0 -0
- package/docs/images/content/vscode/v7-choose-agent.png +0 -0
- package/docs/images/content/vscode/v7-full.png +0 -0
- package/docs/images/content/vscode/v7-onboarding.png +0 -0
- package/docs/v7/cache.mdx +223 -0
- package/docs/v7/copilot/auto-healing.mdx +265 -0
- package/docs/v7/copilot/creating-tests.mdx +156 -0
- package/docs/v7/copilot/github.mdx +143 -0
- package/docs/v7/copilot/running-tests.mdx +149 -0
- package/docs/v7/copilot/setup.mdx +143 -0
- package/docs/v7/enterprise.mdx +3 -110
- package/docs/v7/errors.mdx +248 -0
- package/docs/v7/events.mdx +358 -0
- package/docs/v7/examples/ai.mdx +1 -1
- package/docs/v7/examples/assert.mdx +1 -1
- package/docs/v7/examples/captcha-api.mdx +1 -1
- package/docs/v7/examples/chrome-extension.mdx +1 -1
- package/docs/v7/examples/drag-and-drop.mdx +1 -1
- package/docs/v7/examples/element-not-found.mdx +1 -1
- package/docs/v7/examples/exec-output.mdx +85 -0
- package/docs/v7/examples/exec-pwsh.mdx +83 -0
- package/docs/v7/examples/focus-window.mdx +62 -0
- package/docs/v7/examples/hover-image.mdx +1 -1
- package/docs/v7/examples/hover-text.mdx +1 -1
- package/docs/v7/examples/installer.mdx +1 -1
- package/docs/v7/examples/launch-vscode-linux.mdx +1 -1
- package/docs/v7/examples/match-image.mdx +1 -1
- package/docs/v7/examples/press-keys.mdx +1 -1
- package/docs/v7/examples/scroll-keyboard.mdx +1 -1
- package/docs/v7/examples/scroll-until-image.mdx +1 -1
- package/docs/v7/examples/scroll-until-text.mdx +1 -1
- package/docs/v7/examples/scroll.mdx +1 -1
- package/docs/v7/examples/type.mdx +1 -1
- package/docs/v7/examples/windows-installer.mdx +1 -1
- package/docs/v7/find.mdx +14 -20
- package/docs/v7/{cloud.mdx → hosted.mdx} +43 -5
- package/docs/v7/mcp.mdx +9 -0
- package/docs/v7/provision.mdx +333 -0
- package/docs/v7/quickstart.mdx +30 -2
- package/docs/v7/redraw.mdx +216 -0
- package/docs/v7/running-tests.mdx +1 -1
- package/docs/v7/screenshots.mdx +186 -0
- package/docs/v7/self-hosted.mdx +127 -44
- package/docs/v7/test-results-json.mdx +258 -0
- package/examples/scroll-keyboard.test.mjs +1 -1
- package/examples/scroll.test.mjs +1 -12
- package/interfaces/logger.js +0 -12
- package/interfaces/vitest-plugin.mjs +170 -51
- package/lib/core/Dashcam.js +30 -23
- package/lib/environments.json +22 -0
- package/lib/github-comment.mjs +58 -40
- package/lib/init-project.js +5 -67
- package/lib/resolve-channel.js +42 -12
- package/lib/sentry.js +47 -23
- package/lib/vitest/hooks.mjs +63 -3
- package/{examples → manual}/drag-and-drop.test.mjs +1 -1
- package/manual/exec-stream-logs.test.mjs +25 -0
- package/mcp-server/dist/server.mjs +28 -8
- package/mcp-server/src/server.ts +31 -8
- package/package.json +4 -3
- package/sdk.d.ts +4 -0
- package/sdk.js +45 -15
- package/setup/aws/install-dev-runner.sh +79 -0
- package/setup/aws/spawn-runner.sh +165 -0
- package/test-sentry-span.js +35 -0
- package/vitest.config.mjs +22 -34
- package/vitest.runner.config.mjs +33 -0
- /package/{examples → manual}/flake-diffthreshold-001.test.mjs +0 -0
- /package/{examples → manual}/flake-diffthreshold-01.test.mjs +0 -0
- /package/{examples → manual}/flake-diffthreshold-05.test.mjs +0 -0
- /package/{examples → manual}/flake-noredraw-cache.test.mjs +0 -0
- /package/{examples → manual}/flake-noredraw-nocache.test.mjs +0 -0
- /package/{examples → manual}/flake-redraw-cache.test.mjs +0 -0
- /package/{examples → manual}/flake-redraw-nocache.test.mjs +0 -0
- /package/{examples → manual}/flake-rocket-match.test.mjs +0 -0
- /package/{examples → manual}/flake-shared.mjs +0 -0
- /package/{examples → manual}/no-provision.test.mjs +0 -0
- /package/{examples → manual}/scroll-until-text.test.mjs +0 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "GitHub Copilot Setup"
|
|
3
|
+
sidebarTitle: "IDE Setup"
|
|
4
|
+
description: "Install the TestDriver extension and configure MCP for GitHub Copilot"
|
|
5
|
+
icon: "wrench"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
TestDriver integrates with GitHub Copilot through the VS Code extension and MCP server. This guide walks you through the complete setup.
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
|
|
12
|
+
Before you begin, you'll need:
|
|
13
|
+
|
|
14
|
+
- **GitHub Copilot** — A subscription with MCP access. A [free tier](https://github.com/features/copilot/plans) is available.
|
|
15
|
+
- **TestDriver Account** — Create a free account at [console.testdriver.ai](https://console.testdriver.ai/team) to get your API key. 60 free device minutes, no credit card required.
|
|
16
|
+
- **VS Code** — The TestDriver extension provides the best experience with live preview and integrated test running.
|
|
17
|
+
|
|
18
|
+
## Setup Steps
|
|
19
|
+
|
|
20
|
+
<Steps>
|
|
21
|
+
<Step title="Install the TestDriver Extension">
|
|
22
|
+
<Card
|
|
23
|
+
horizontal
|
|
24
|
+
title="Install TestDriver for VS Code"
|
|
25
|
+
arrow
|
|
26
|
+
href="vscode:extension/testdriver.testdriver"
|
|
27
|
+
icon="/images/content/extension/vscode.svg"
|
|
28
|
+
></Card>
|
|
29
|
+
|
|
30
|
+
The extension provides:
|
|
31
|
+
- One-click sign-in and project initialization
|
|
32
|
+
- Live preview panel for watching tests execute
|
|
33
|
+
- MCP server configuration
|
|
34
|
+
</Step>
|
|
35
|
+
|
|
36
|
+
<Step title="Sign Into TestDriver">
|
|
37
|
+
Sign in to connect your account and API key.
|
|
38
|
+
|
|
39
|
+
1. Open the command palette (`Cmd+Shift+P` or `Ctrl+Shift+P`)
|
|
40
|
+
2. Run **TestDriver: Login**
|
|
41
|
+
3. Your browser will open to the TestDriver sign-in page
|
|
42
|
+
4. Sign in (or create an account)
|
|
43
|
+
5. You'll be redirected back to VS Code, now signed in
|
|
44
|
+
|
|
45
|
+
<Tip>
|
|
46
|
+
The extension automatically saves your API key to VS Code's secure storage and your workspace `.env` file.
|
|
47
|
+
</Tip>
|
|
48
|
+
</Step>
|
|
49
|
+
|
|
50
|
+
<Step title="Initialize Your Project">
|
|
51
|
+
Set up TestDriver in your project with a single command.
|
|
52
|
+
|
|
53
|
+
1. Open the command palette (`Cmd+Shift+P` or `Ctrl+Shift+P`)
|
|
54
|
+
2. Run **TestDriver: Init Project**
|
|
55
|
+
|
|
56
|
+
This command:
|
|
57
|
+
- Creates a `package.json` with TestDriver and Vitest dependencies
|
|
58
|
+
- Generates a `vitest.config.mjs` with proper timeout settings
|
|
59
|
+
- Creates example test files in `tests/`
|
|
60
|
+
- Sets up `.env` with your API key
|
|
61
|
+
- Creates the TestDriver agent file at `.github/agents/testdriver.agent.md`
|
|
62
|
+
- Configures the MCP server
|
|
63
|
+
|
|
64
|
+
<Note>
|
|
65
|
+
If you already have a `package.json`, the command will add the necessary dependencies to it.
|
|
66
|
+
</Note>
|
|
67
|
+
</Step>
|
|
68
|
+
|
|
69
|
+
<Step title="Start the MCP Server">
|
|
70
|
+
The MCP server enables GitHub Copilot to control TestDriver sandboxes.
|
|
71
|
+
|
|
72
|
+
After initialization, the MCP configuration is created at `.vscode/mcp.json`:
|
|
73
|
+
|
|
74
|
+
```json .vscode/mcp.json
|
|
75
|
+
{
|
|
76
|
+
"servers": {
|
|
77
|
+
"testdriver": {
|
|
78
|
+
"command": "npx",
|
|
79
|
+
"args": ["-p", "testdriverai", "testdriverai-mcp"],
|
|
80
|
+
"env": {
|
|
81
|
+
"TD_PREVIEW": "ide",
|
|
82
|
+
"TD_API_KEY": "your-api-key"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**To start the MCP server:**
|
|
90
|
+
|
|
91
|
+
1. Open the command palette (`Cmd+Shift+P` or `Ctrl+Shift+P`)
|
|
92
|
+
2. Run **MCP: List Servers**
|
|
93
|
+
3. Click on the **testdriver** server
|
|
94
|
+
4. Select **Start Server**
|
|
95
|
+
|
|
96
|
+
You can also click the MCP icon in the status bar to manage servers.
|
|
97
|
+
|
|
98
|
+
<Tip>
|
|
99
|
+
See the [VS Code MCP documentation](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) for more details on managing MCP servers.
|
|
100
|
+
</Tip>
|
|
101
|
+
|
|
102
|
+
<Warning>
|
|
103
|
+
Make sure your API key is set. The extension uses the key from your sign-in, but you can also set it via the `TD_API_KEY` environment variable.
|
|
104
|
+
</Warning>
|
|
105
|
+
</Step>
|
|
106
|
+
|
|
107
|
+
<Step title="Install Vitest Extension (Recommended)">
|
|
108
|
+
For the best experience running tests, install the Vitest extension:
|
|
109
|
+
|
|
110
|
+
<Card
|
|
111
|
+
horizontal
|
|
112
|
+
title="Vitest Extension"
|
|
113
|
+
arrow
|
|
114
|
+
href="vscode:extension/vitest.explorer"
|
|
115
|
+
icon="flask-vial"
|
|
116
|
+
>
|
|
117
|
+
Run tests with GUI mode from the Test Explorer
|
|
118
|
+
</Card>
|
|
119
|
+
|
|
120
|
+
After installation, you'll see a beaker icon in the sidebar for accessing the Test Explorer.
|
|
121
|
+
</Step>
|
|
122
|
+
</Steps>
|
|
123
|
+
|
|
124
|
+
## Verify Your Setup
|
|
125
|
+
|
|
126
|
+
To verify everything is configured correctly:
|
|
127
|
+
|
|
128
|
+
1. Open the command palette and run **TestDriver: Check Status**
|
|
129
|
+
2. You should see:
|
|
130
|
+
- ✅ Signed in
|
|
131
|
+
- ✅ MCP server configured
|
|
132
|
+
- ✅ Project initialized
|
|
133
|
+
|
|
134
|
+
## The Agent File
|
|
135
|
+
|
|
136
|
+
During initialization, TestDriver creates an agent file at `.github/agents/testdriver.agent.md`. This file tells GitHub Copilot how to use TestDriver's MCP tools.
|
|
137
|
+
|
|
138
|
+
The agent has access to tools like:
|
|
139
|
+
- `session_start` — Launch a sandbox with Chrome or other apps
|
|
140
|
+
- `find` / `click` / `type` — Interact with elements on screen
|
|
141
|
+
- `assert` — Verify conditions using AI vision
|
|
142
|
+
- `screenshot` — Capture the current screen state
|
|
143
|
+
|
package/docs/v7/enterprise.mdx
CHANGED
|
@@ -1,116 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Enterprise"
|
|
3
3
|
sidebarTitle: "Enterprise"
|
|
4
|
-
description: "
|
|
4
|
+
description: "Self-hosted enterprise deployments with assisted setup and dedicated support"
|
|
5
5
|
icon: "building"
|
|
6
|
+
redirect: "/v7/self-hosted"
|
|
6
7
|
---
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
## Why Enterprise?
|
|
10
|
-
|
|
11
|
-
<CardGroup cols={2}>
|
|
12
|
-
<Card title="Air-Gapped Security" icon="shield-check">
|
|
13
|
-
Deploy everything in your environment. No data leaves your network. Complete isolation from external services.
|
|
14
|
-
</Card>
|
|
15
|
-
<Card title="Full Customization" icon="gear">
|
|
16
|
-
Custom integrations, dedicated infrastructure, and tailored solutions for your unique requirements.
|
|
17
|
-
</Card>
|
|
18
|
-
<Card title="Self-Hosted Dashboard & API" icon="server">
|
|
19
|
-
Run the entire TestDriver stack — dashboard, API, and test infrastructure — within your own environment.
|
|
20
|
-
</Card>
|
|
21
|
-
<Card title="Dedicated Support" icon="headset">
|
|
22
|
-
Direct access to our engineering team for implementation, customization, and ongoing support.
|
|
23
|
-
</Card>
|
|
24
|
-
</CardGroup>
|
|
25
|
-
|
|
26
|
-
## Who Needs Enterprise?
|
|
27
|
-
|
|
28
|
-
Enterprise is designed for organizations that:
|
|
29
|
-
|
|
30
|
-
- **Require air-gapped deployments** — Regulated industries, government, defense, or strict compliance requirements
|
|
31
|
-
- **Cannot use external APIs** — Data must never leave your network perimeter
|
|
32
|
-
- **Need custom integrations** — Unique CI/CD systems, internal tools, or specialized workflows
|
|
33
|
-
- **Want dedicated support** — Direct engineering support for complex implementations
|
|
34
|
-
|
|
35
|
-
## What's Included
|
|
36
|
-
|
|
37
|
-
### Fully Self-Hosted Stack
|
|
38
|
-
|
|
39
|
-
Unlike [Self-Hosted](/v7/self-hosted) (which uses TestDriver's hosted dashboard and API), Enterprise deploys everything in your environment:
|
|
40
|
-
|
|
41
|
-
| Component | Self-Hosted | Enterprise |
|
|
42
|
-
|-----------|-------------|------------|
|
|
43
|
-
| Test Sandboxes | Your infrastructure | Your infrastructure |
|
|
44
|
-
| Dashboard | TestDriver hosted | Your infrastructure |
|
|
45
|
-
| API | TestDriver hosted | Your infrastructure |
|
|
46
|
-
| AI Processing | Your API keys | Your infrastructure |
|
|
47
|
-
| Data Storage | Your AWS account | Your infrastructure |
|
|
48
|
-
|
|
49
|
-
### Custom Contract Terms
|
|
50
|
-
|
|
51
|
-
- Volume-based pricing
|
|
52
|
-
- Custom SLAs
|
|
53
|
-
- Dedicated support channels
|
|
54
|
-
- Professional services for implementation
|
|
55
|
-
- Training for your team
|
|
56
|
-
|
|
57
|
-
## Implementation Process
|
|
58
|
-
|
|
59
|
-
<Steps>
|
|
60
|
-
<Step title="Discovery Call">
|
|
61
|
-
Discuss your requirements, security constraints, and integration needs with our team.
|
|
62
|
-
</Step>
|
|
63
|
-
|
|
64
|
-
<Step title="Architecture Review">
|
|
65
|
-
Our engineers design a deployment architecture that meets your security and compliance requirements.
|
|
66
|
-
</Step>
|
|
67
|
-
|
|
68
|
-
<Step title="Deployment">
|
|
69
|
-
We work with your team to deploy TestDriver within your environment, including dashboard, API, and test infrastructure.
|
|
70
|
-
</Step>
|
|
71
|
-
|
|
72
|
-
<Step title="Integration">
|
|
73
|
-
Connect TestDriver to your CI/CD pipelines, internal tools, and workflows.
|
|
74
|
-
</Step>
|
|
75
|
-
|
|
76
|
-
<Step title="Training & Handoff">
|
|
77
|
-
Comprehensive training for your team on operating and maintaining the deployment.
|
|
78
|
-
</Step>
|
|
79
|
-
</Steps>
|
|
80
|
-
|
|
81
|
-
## Security & Compliance
|
|
82
|
-
|
|
83
|
-
Enterprise deployments support:
|
|
84
|
-
|
|
85
|
-
- **SOC 2** compliance requirements
|
|
86
|
-
- **HIPAA** for healthcare applications
|
|
87
|
-
- **FedRAMP** for government deployments
|
|
88
|
-
- **PCI DSS** for payment processing
|
|
89
|
-
- **Custom compliance frameworks** as needed
|
|
90
|
-
|
|
91
|
-
<Note>
|
|
92
|
-
All data remains within your network perimeter. TestDriver has no access to your test results, application data, or infrastructure.
|
|
93
|
-
</Note>
|
|
94
|
-
|
|
95
|
-
## Comparison: Self-Hosted vs Enterprise
|
|
96
|
-
|
|
97
|
-
| Feature | Self-Hosted | Enterprise |
|
|
98
|
-
|---------|-------------|------------|
|
|
99
|
-
| **Test Infrastructure** | Your AWS | Your infrastructure (any) |
|
|
100
|
-
| **Dashboard** | TestDriver cloud | Your infrastructure |
|
|
101
|
-
| **API** | TestDriver cloud | Your infrastructure |
|
|
102
|
-
| **Data Location** | Your AWS + TestDriver | 100% your infrastructure |
|
|
103
|
-
| **Network Requirements** | Internet access | Can be fully air-gapped |
|
|
104
|
-
| **Cloud Providers** | AWS only | Any (AWS, Azure, GCP, on-prem) |
|
|
105
|
-
| **Support** | Standard | Dedicated engineering |
|
|
106
|
-
| **Contract** | Standard licensing | Custom terms |
|
|
107
|
-
|
|
108
|
-
## Get Started
|
|
109
|
-
|
|
110
|
-
<Card
|
|
111
|
-
title="Schedule a Consultation"
|
|
112
|
-
icon="calendar"
|
|
113
|
-
href="https://calendly.com/d/cq23-qyn-3v6/testdriver-ai-demo"
|
|
114
|
-
>
|
|
115
|
-
Discuss your requirements with our team and get a custom proposal for your Enterprise deployment.
|
|
116
|
-
</Card>
|
|
9
|
+
This page has moved to [Self-Hosted](/v7/self-hosted).
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Errors"
|
|
3
|
+
sidebarTitle: "Errors"
|
|
4
|
+
description: "Custom error classes and error handling"
|
|
5
|
+
icon: "triangle-exclamation"
|
|
6
|
+
mode: "wide"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
TestDriver provides custom error classes with rich debugging information. These are exported from the SDK and can be used for `instanceof` checks in your tests.
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
import TestDriver, { ElementNotFoundError, AIError } from 'testdriverai';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## ElementNotFoundError
|
|
18
|
+
|
|
19
|
+
Thrown when `find()` cannot locate an element on screen, or when calling `click()`/`hover()` on an unfound element.
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
try {
|
|
23
|
+
await testdriver.find('nonexistent button').click();
|
|
24
|
+
} catch (error) {
|
|
25
|
+
if (error instanceof ElementNotFoundError) {
|
|
26
|
+
console.log(error.description); // "nonexistent button"
|
|
27
|
+
console.log(error.screenshotPath); // path to debug screenshot
|
|
28
|
+
console.log(error.pixelDiffPath); // path to pixel diff image
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Properties
|
|
34
|
+
|
|
35
|
+
<ParamField path="name" type="string">
|
|
36
|
+
Always `"ElementNotFoundError"`.
|
|
37
|
+
</ParamField>
|
|
38
|
+
|
|
39
|
+
<ParamField path="message" type="string">
|
|
40
|
+
Enhanced message with a debug block containing element description, cache status, similarity scores, and AI response details.
|
|
41
|
+
</ParamField>
|
|
42
|
+
|
|
43
|
+
<ParamField path="description" type="string">
|
|
44
|
+
The original element description passed to `find()`.
|
|
45
|
+
</ParamField>
|
|
46
|
+
|
|
47
|
+
<ParamField path="screenshotPath" type="string | null">
|
|
48
|
+
Absolute path to a debug screenshot saved at the time of failure. Written to `<os.tmpdir>/testdriver-debug/screenshot-<timestamp>.png`.
|
|
49
|
+
</ParamField>
|
|
50
|
+
|
|
51
|
+
<ParamField path="pixelDiffPath" type="string | null">
|
|
52
|
+
Absolute path to a pixel diff image showing the comparison between the cached and current screenshots. Written to `<os.tmpdir>/testdriver-debug/pixel-diff-error-<timestamp>.png`. Only present when cache was involved.
|
|
53
|
+
</ParamField>
|
|
54
|
+
|
|
55
|
+
<ParamField path="cachedImagePath" type="string | null">
|
|
56
|
+
URL to the cached image that was compared against.
|
|
57
|
+
</ParamField>
|
|
58
|
+
|
|
59
|
+
<ParamField path="aiResponse" type="object | null">
|
|
60
|
+
Sanitized AI response object. Large binary fields (`croppedImage`, `screenshot`, `pixelDiffImage`) are removed. Contains cache metadata like `similarity`, `cacheHit`, `cacheStrategy`, `cacheDiffPercent`, and `threshold`.
|
|
61
|
+
</ParamField>
|
|
62
|
+
|
|
63
|
+
<ParamField path="timestamp" type="string">
|
|
64
|
+
ISO 8601 timestamp of when the error was created.
|
|
65
|
+
</ParamField>
|
|
66
|
+
|
|
67
|
+
### Enhanced Message
|
|
68
|
+
|
|
69
|
+
The error message is automatically enhanced with debugging information:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
Element not found: "submit button"
|
|
73
|
+
|
|
74
|
+
=== Element Debug Info ===
|
|
75
|
+
Element: submit button
|
|
76
|
+
Cache Hit: false
|
|
77
|
+
Similarity: 0.23
|
|
78
|
+
Cache Strategy: pixel-diff
|
|
79
|
+
Threshold: 0.05
|
|
80
|
+
AI Response Element: null
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Stack Trace Cleaning
|
|
84
|
+
|
|
85
|
+
Stack traces are automatically cleaned to remove internal SDK frames (`Element.*`, `sdk.js` internals), showing only your test code for easier debugging.
|
|
86
|
+
|
|
87
|
+
## AIError
|
|
88
|
+
|
|
89
|
+
Thrown when `act()` exhausts all retry attempts.
|
|
90
|
+
|
|
91
|
+
```javascript
|
|
92
|
+
try {
|
|
93
|
+
await testdriver.act('perform complex workflow', { tries: 3 });
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (error instanceof AIError) {
|
|
96
|
+
console.log(error.task); // "perform complex workflow"
|
|
97
|
+
console.log(error.tries); // 3
|
|
98
|
+
console.log(error.duration); // 15234 (ms)
|
|
99
|
+
console.log(error.cause); // underlying Error
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Properties
|
|
105
|
+
|
|
106
|
+
<ParamField path="name" type="string">
|
|
107
|
+
Always `"AIError"`.
|
|
108
|
+
</ParamField>
|
|
109
|
+
|
|
110
|
+
<ParamField path="message" type="string">
|
|
111
|
+
Enhanced message with execution details block.
|
|
112
|
+
</ParamField>
|
|
113
|
+
|
|
114
|
+
<ParamField path="task" type="string">
|
|
115
|
+
The task description passed to `act()`.
|
|
116
|
+
</ParamField>
|
|
117
|
+
|
|
118
|
+
<ParamField path="tries" type="number">
|
|
119
|
+
Number of attempts that were made.
|
|
120
|
+
</ParamField>
|
|
121
|
+
|
|
122
|
+
<ParamField path="maxTries" type="number">
|
|
123
|
+
Maximum number of attempts configured.
|
|
124
|
+
</ParamField>
|
|
125
|
+
|
|
126
|
+
<ParamField path="duration" type="number">
|
|
127
|
+
Total execution time in milliseconds.
|
|
128
|
+
</ParamField>
|
|
129
|
+
|
|
130
|
+
<ParamField path="cause" type="Error | undefined">
|
|
131
|
+
The underlying error that caused the final failure.
|
|
132
|
+
</ParamField>
|
|
133
|
+
|
|
134
|
+
<ParamField path="timestamp" type="string">
|
|
135
|
+
ISO 8601 timestamp of when the error was created.
|
|
136
|
+
</ParamField>
|
|
137
|
+
|
|
138
|
+
### Enhanced Message
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
AI failed: Element not found after 3 attempts
|
|
142
|
+
|
|
143
|
+
=== AI Execution Details ===
|
|
144
|
+
Task: perform complex workflow
|
|
145
|
+
Tries: 3 / 3
|
|
146
|
+
Duration: 15234ms
|
|
147
|
+
Cause: ElementNotFoundError: Element not found: "submit button"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Internal Error Classes
|
|
151
|
+
|
|
152
|
+
These errors are used internally by the agent and are not exported, but may appear as the `cause` of an `AIError`:
|
|
153
|
+
|
|
154
|
+
### MatchError
|
|
155
|
+
|
|
156
|
+
Thrown when element matching fails (text, image, or assertion).
|
|
157
|
+
|
|
158
|
+
| Property | Type | Description |
|
|
159
|
+
|---|---|---|
|
|
160
|
+
| `fatal` | `boolean` | If `true`, cannot be healed. Default: `false` |
|
|
161
|
+
| `attachScreenshot` | `boolean` | Always `true` — a screenshot is attached to the error |
|
|
162
|
+
|
|
163
|
+
### CommandError
|
|
164
|
+
|
|
165
|
+
Thrown for invalid arguments or unsupported operations.
|
|
166
|
+
|
|
167
|
+
| Property | Type | Description |
|
|
168
|
+
|---|---|---|
|
|
169
|
+
| `fatal` | `boolean` | Always `true` |
|
|
170
|
+
| `attachScreenshot` | `boolean` | Always `false` |
|
|
171
|
+
|
|
172
|
+
## Soft Assert Mode
|
|
173
|
+
|
|
174
|
+
Inside `act()`, assertions run in **soft assert mode**. When an assertion fails, it returns the failure result instead of throwing, allowing the AI to process the failure and adjust its approach.
|
|
175
|
+
|
|
176
|
+
```javascript
|
|
177
|
+
// Inside act(), assertion failures don't throw
|
|
178
|
+
await testdriver.act('verify the dashboard shows correct data', {
|
|
179
|
+
tries: 3,
|
|
180
|
+
});
|
|
181
|
+
// The AI can see assertion results and self-correct
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
This is automatic — you don't need to configure it. Regular `assert()` calls outside of `act()` will throw normally on failure.
|
|
185
|
+
|
|
186
|
+
## Error Handling Patterns
|
|
187
|
+
|
|
188
|
+
### Catching Specific Errors
|
|
189
|
+
|
|
190
|
+
```javascript
|
|
191
|
+
import TestDriver, { ElementNotFoundError, AIError } from 'testdriverai';
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
await testdriver.find('submit button').click();
|
|
195
|
+
} catch (error) {
|
|
196
|
+
if (error instanceof ElementNotFoundError) {
|
|
197
|
+
// Element wasn't found — check screenshot for debugging
|
|
198
|
+
console.log('Debug screenshot:', error.screenshotPath);
|
|
199
|
+
} else if (error instanceof AIError) {
|
|
200
|
+
// AI exhausted retries
|
|
201
|
+
console.log(`Failed after ${error.tries} tries in ${error.duration}ms`);
|
|
202
|
+
} else {
|
|
203
|
+
throw error; // Unexpected error
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Using Debug Screenshots
|
|
209
|
+
|
|
210
|
+
```javascript
|
|
211
|
+
try {
|
|
212
|
+
const el = await testdriver.find('checkout button');
|
|
213
|
+
await el.click();
|
|
214
|
+
} catch (error) {
|
|
215
|
+
if (error instanceof ElementNotFoundError) {
|
|
216
|
+
// Screenshot of what the screen looked like
|
|
217
|
+
console.log('Screen:', error.screenshotPath);
|
|
218
|
+
// Pixel diff showing cache comparison
|
|
219
|
+
console.log('Diff:', error.pixelDiffPath);
|
|
220
|
+
// Full AI response metadata
|
|
221
|
+
console.log('AI:', JSON.stringify(error.aiResponse, null, 2));
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Types
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
class ElementNotFoundError extends Error {
|
|
230
|
+
name: 'ElementNotFoundError';
|
|
231
|
+
description: string;
|
|
232
|
+
screenshotPath: string | null;
|
|
233
|
+
pixelDiffPath: string | null;
|
|
234
|
+
cachedImagePath: string | null;
|
|
235
|
+
aiResponse: Record<string, any> | null;
|
|
236
|
+
timestamp: string;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
class AIError extends Error {
|
|
240
|
+
name: 'AIError';
|
|
241
|
+
task: string;
|
|
242
|
+
tries: number;
|
|
243
|
+
maxTries: number;
|
|
244
|
+
duration: number;
|
|
245
|
+
cause?: Error;
|
|
246
|
+
timestamp: string;
|
|
247
|
+
}
|
|
248
|
+
```
|