testdriverai 7.2.9 → 7.2.11
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/.github/workflows/testdriver.yml +127 -0
- package/.testdriver/last-sandbox +7 -0
- package/agent/events.js +1 -0
- package/agent/index.js +71 -54
- package/agent/lib/sandbox.js +11 -1
- package/agents.md +393 -0
- package/debug/01-table-initial.png +0 -0
- package/debug/02-after-ai-explore.png +0 -0
- package/debug/02-after-scroll.png +0 -0
- package/docs/docs.json +87 -126
- package/docs/v7/_drafts/caching.mdx +2 -2
- package/docs/v7/{getting-started → _drafts}/installation.mdx +0 -66
- package/docs/v7/{features/coverage.mdx → _drafts/powerful.mdx} +1 -90
- package/docs/v7/{features → _drafts}/scalable.mdx +126 -4
- package/docs/v7/_drafts/screenshot.mdx +155 -0
- package/docs/v7/_drafts/writing-tests.mdx +25 -0
- package/docs/v7/{api/act.mdx → ai.mdx} +27 -27
- package/docs/v7/{api/assert.mdx → assert.mdx} +3 -3
- package/docs/v7/aws-setup.mdx +338 -0
- package/docs/v7/caching.mdx +128 -0
- package/docs/v7/ci-cd.mdx +605 -0
- package/docs/v7/{api/click.mdx → click.mdx} +4 -4
- package/docs/v7/cloud.mdx +120 -0
- package/docs/v7/customizing-devices.mdx +129 -0
- package/docs/v7/{api/dashcam.mdx → dashcam.mdx} +0 -78
- package/docs/v7/{api/doubleClick.mdx → double-click.mdx} +5 -5
- package/docs/v7/{api/elements.mdx → elements.mdx} +1 -54
- package/docs/v7/enterprise.mdx +116 -0
- package/docs/v7/examples.mdx +5 -0
- package/docs/v7/{api/exec.mdx → exec.mdx} +3 -3
- package/docs/v7/{api/find.mdx → find.mdx} +17 -21
- package/docs/v7/{api/focusApplication.mdx → focus-application.mdx} +3 -3
- package/docs/v7/generating-tests.mdx +36 -0
- package/docs/v7/{api/hover.mdx → hover.mdx} +3 -3
- package/docs/v7/locating-elements.mdx +71 -0
- package/docs/v7/making-assertions.mdx +32 -0
- package/docs/v7/{api/mouseDown.mdx → mouse-down.mdx} +7 -7
- package/docs/v7/{api/mouseUp.mdx → mouse-up.mdx} +8 -8
- package/docs/v7/performing-actions.mdx +51 -0
- package/docs/v7/{api/pressKeys.mdx → press-keys.mdx} +3 -3
- package/docs/v7/quickstart.mdx +162 -0
- package/docs/v7/reusable-code.mdx +240 -0
- package/docs/v7/{api/rightClick.mdx → right-click.mdx} +5 -5
- package/docs/v7/running-tests.mdx +181 -0
- package/docs/v7/{api/scroll.mdx → scroll.mdx} +3 -3
- package/docs/v7/secrets.mdx +115 -0
- package/docs/v7/self-hosted.mdx +66 -0
- package/docs/v7/{api/type.mdx → type.mdx} +3 -3
- package/docs/v7/variables.mdx +111 -0
- package/docs/v7/waiting-for-elements.mdx +66 -0
- package/docs/v7/what-is-testdriver.mdx +54 -0
- package/lib/vitest/hooks.mjs +80 -68
- package/package.json +1 -1
- package/sdk.d.ts +22 -9
- package/sdk.js +177 -44
- package/test/manual/reconnect-provision.test.mjs +49 -0
- package/test/manual/reconnect-signin.test.mjs +41 -0
- package/test/testdriver/ai.test.mjs +30 -0
- package/test/testdriver/setup/testHelpers.mjs +0 -1
- package/test/testdriver/windows-installer.test.mjs +61 -0
- package/tests/table-sort-enrollments.test.mjs +72 -0
- package/tests/table-sort-experiment.test.mjs +42 -0
- package/tests/table-sort-setup.test.mjs +59 -0
- package/vitest.config.mjs +1 -0
- package/docs/v7/api/assertions.mdx +0 -403
- package/docs/v7/api/sandbox.mdx +0 -404
- package/docs/v7/features/ai-native.mdx +0 -413
- package/docs/v7/features/application-logs.mdx +0 -353
- package/docs/v7/features/browser-logs.mdx +0 -414
- package/docs/v7/features/cache-management.mdx +0 -402
- package/docs/v7/features/continuous-testing.mdx +0 -346
- package/docs/v7/features/data-driven-testing.mdx +0 -441
- package/docs/v7/features/easy-to-write.mdx +0 -280
- package/docs/v7/features/enterprise.mdx +0 -656
- package/docs/v7/features/fast.mdx +0 -406
- package/docs/v7/features/managed-sandboxes.mdx +0 -384
- package/docs/v7/features/network-monitoring.mdx +0 -568
- package/docs/v7/features/parallel-execution.mdx +0 -381
- package/docs/v7/features/powerful.mdx +0 -531
- package/docs/v7/features/sandbox-customization.mdx +0 -229
- package/docs/v7/features/stable.mdx +0 -473
- package/docs/v7/features/system-performance.mdx +0 -616
- package/docs/v7/features/test-analytics.mdx +0 -373
- package/docs/v7/features/test-cases.mdx +0 -393
- package/docs/v7/features/test-replays.mdx +0 -408
- package/docs/v7/features/test-reports.mdx +0 -308
- package/docs/v7/getting-started/debugging-tests.mdx +0 -382
- package/docs/v7/getting-started/quickstart.mdx +0 -90
- package/docs/v7/getting-started/running-tests.mdx +0 -173
- package/docs/v7/getting-started/setting-up-in-ci.mdx +0 -612
- package/docs/v7/getting-started/writing-tests.mdx +0 -534
- package/docs/v7/overview/what-is-testdriver.mdx +0 -386
- package/docs/v7/presets/chrome-extension.mdx +0 -248
- package/docs/v7/presets/chrome.mdx +0 -300
- package/docs/v7/presets/electron.mdx +0 -460
- package/docs/v7/presets/vscode.mdx +0 -417
- package/docs/v7/presets/webapp.mdx +0 -393
- package/vitest.config.js +0 -18
- /package/docs/v7/{commands → _drafts/commands}/assert.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/exec.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/focus-application.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/hover-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/hover-text.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/if.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/match-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/press-keys.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/remember.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/run.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/scroll-until-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/scroll-until-text.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/scroll.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/type.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/wait-for-image.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/wait-for-text.mdx +0 -0
- /package/docs/v7/{commands → _drafts/commands}/wait.mdx +0 -0
- /package/docs/v7/{getting-started → _drafts}/configuration.mdx +0 -0
- /package/docs/v7/{features → _drafts}/observable.mdx +0 -0
- /package/docs/v7/{platforms → _drafts/platforms}/linux.mdx +0 -0
- /package/docs/v7/{platforms → _drafts/platforms}/macos.mdx +0 -0
- /package/docs/v7/{platforms → _drafts/platforms}/windows.mdx +0 -0
- /package/docs/v7/{playwright.mdx → _drafts/playwright.mdx} +0 -0
- /package/docs/v7/{overview → _drafts}/readme.mdx +0 -0
- /package/docs/v7/{features → _drafts}/reports.mdx +0 -0
- /package/docs/v7/{api/client.mdx → client.mdx} +0 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "AWS Setup Guide"
|
|
3
|
+
sidebarTitle: "AWS Setup Guide"
|
|
4
|
+
description: "Deploy TestDriver on your AWS infrastructure using CloudFormation"
|
|
5
|
+
icon: "aws"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
This guide walks you through setting up self-hosted TestDriver instances on AWS. By the end, you'll have a complete infrastructure that can spawn test environments on-demand and integrate with your CI/CD pipelines.
|
|
9
|
+
|
|
10
|
+
```mermaid
|
|
11
|
+
graph LR
|
|
12
|
+
A[Vitest] <--> B[api.testdriver.ai]
|
|
13
|
+
B <--> C[Your AWS EC2 Instance]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Overview
|
|
17
|
+
|
|
18
|
+
The setup process involves three main steps:
|
|
19
|
+
|
|
20
|
+
1. **CloudFormation Infrastructure** — Deploy our template to create VPC, security groups, IAM roles, and launch templates
|
|
21
|
+
2. **On-Demand Instance Spawning** — Use `spawn-runner.sh` to launch TestDriver instances when you need to run tests
|
|
22
|
+
3. **CI/CD Integration** — Automate the lifecycle in GitHub Actions: spawn instance → run tests → terminate instance
|
|
23
|
+
|
|
24
|
+
## Prerequisites
|
|
25
|
+
|
|
26
|
+
Before you begin, ensure you have:
|
|
27
|
+
|
|
28
|
+
- AWS account with CloudFormation permissions
|
|
29
|
+
- [AWS CLI](https://aws.amazon.com/cli/) installed and configured (`aws configure`)
|
|
30
|
+
- Access to the TestDriver AMI — [Contact us](https://form.typeform.com/to/UECf9rDx?typeform-source=testdriver.ai) with your AWS region
|
|
31
|
+
- A GitHub repository for your tests
|
|
32
|
+
|
|
33
|
+
<Tip>
|
|
34
|
+
The TestDriver Golden Image AMI ID is `ami-086b5b4b86d78987c`. Contact us to get access in your preferred AWS region.
|
|
35
|
+
</Tip>
|
|
36
|
+
|
|
37
|
+
## Step 1: Deploy CloudFormation Stack
|
|
38
|
+
|
|
39
|
+
Our CloudFormation template creates all the AWS infrastructure you need:
|
|
40
|
+
|
|
41
|
+
- Dedicated VPC with public subnet
|
|
42
|
+
- Security group with required port access
|
|
43
|
+
- IAM roles and instance profiles
|
|
44
|
+
- EC2 launch template for instance creation
|
|
45
|
+
|
|
46
|
+
Download the template from the [TestDriver CLI repository](https://github.com/testdriverai/testdriverai/tree/main/setup/aws/cloudformation.yaml), then deploy:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
aws cloudformation deploy \
|
|
50
|
+
--template-file setup/aws/cloudformation.yaml \
|
|
51
|
+
--stack-name testdriver-infrastructure \
|
|
52
|
+
--parameter-overrides \
|
|
53
|
+
ProjectTag=testdriver \
|
|
54
|
+
AllowedIngressCidr=0.0.0.0/0 \
|
|
55
|
+
InstanceType=c5.xlarge \
|
|
56
|
+
CreateKeyPair=true \
|
|
57
|
+
--capabilities CAPABILITY_IAM
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
<Warning>
|
|
61
|
+
**Security**: Replace `AllowedIngressCidr=0.0.0.0/0` with your specific IP ranges to restrict VPC access.
|
|
62
|
+
</Warning>
|
|
63
|
+
|
|
64
|
+
### Get Your Launch Template ID
|
|
65
|
+
|
|
66
|
+
After deployment completes, retrieve the launch template ID:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
aws cloudformation describe-stacks \
|
|
70
|
+
--stack-name testdriver-infrastructure \
|
|
71
|
+
--query 'Stacks[0].Outputs[?OutputKey==`LaunchTemplateId`].OutputValue' \
|
|
72
|
+
--output text
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
<Tip>
|
|
76
|
+
**Save this ID** — you'll need it for spawning instances and CI configuration.
|
|
77
|
+
</Tip>
|
|
78
|
+
|
|
79
|
+
## Step 2: Spawn Test Instances
|
|
80
|
+
|
|
81
|
+
Use the `spawn-runner.sh` script to launch instances on-demand. This script:
|
|
82
|
+
|
|
83
|
+
- Launches a new EC2 instance using your launch template
|
|
84
|
+
- Waits for the instance to be ready
|
|
85
|
+
- Completes the TestDriver handshake
|
|
86
|
+
- Returns instance details for test execution
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Set environment variables
|
|
90
|
+
export AWS_REGION=us-east-2
|
|
91
|
+
export AMI_ID=ami-086b5b4b86d78987c
|
|
92
|
+
export AWS_LAUNCH_TEMPLATE_ID=lt-your-template-id
|
|
93
|
+
export RESOLUTION=1440x900 # Optional, default is 1440x900
|
|
94
|
+
|
|
95
|
+
# Spawn an instance
|
|
96
|
+
./setup/aws/spawn-runner.sh
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Output:
|
|
100
|
+
```
|
|
101
|
+
PUBLIC_IP=1.2.3.4
|
|
102
|
+
INSTANCE_ID=i-1234567890abcdef0
|
|
103
|
+
AWS_REGION=us-east-2
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Run Tests Against Your Instance
|
|
107
|
+
|
|
108
|
+
With Vitest, specify the instance IP using the `TD_VM` environment variable:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
TD_API_KEY=your-api-key TD_VM=1.2.3.4 npx vitest run
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Terminate Instances
|
|
115
|
+
|
|
116
|
+
Always terminate instances after tests complete to avoid unnecessary costs:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
aws ec2 terminate-instances \
|
|
120
|
+
--instance-ids i-1234567890abcdef0 \
|
|
121
|
+
--region us-east-2
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
<Note>
|
|
125
|
+
Instances are tagged with `Name=TestDriverRunner` and your `ProjectTag` for easy identification in the AWS console.
|
|
126
|
+
</Note>
|
|
127
|
+
|
|
128
|
+
## Step 3: GitHub Actions Integration
|
|
129
|
+
|
|
130
|
+
Automate the full lifecycle in your CI/CD pipeline. This workflow spawns an instance, runs tests, and terminates the instance:
|
|
131
|
+
|
|
132
|
+
```yaml .github/workflows/test.yml
|
|
133
|
+
name: TestDriver Self-Hosted
|
|
134
|
+
|
|
135
|
+
on:
|
|
136
|
+
push:
|
|
137
|
+
branches: [main]
|
|
138
|
+
pull_request:
|
|
139
|
+
|
|
140
|
+
# Prevent concurrent runs from competing for resources
|
|
141
|
+
concurrency:
|
|
142
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
143
|
+
cancel-in-progress: true
|
|
144
|
+
|
|
145
|
+
jobs:
|
|
146
|
+
test:
|
|
147
|
+
runs-on: ubuntu-latest
|
|
148
|
+
steps:
|
|
149
|
+
- name: Checkout repository
|
|
150
|
+
uses: actions/checkout@v4
|
|
151
|
+
|
|
152
|
+
- name: Setup Node.js
|
|
153
|
+
uses: actions/setup-node@v4
|
|
154
|
+
with:
|
|
155
|
+
node-version: '20'
|
|
156
|
+
|
|
157
|
+
- name: Install dependencies
|
|
158
|
+
run: npm install
|
|
159
|
+
|
|
160
|
+
- name: Setup AWS Instance
|
|
161
|
+
id: aws-setup
|
|
162
|
+
run: |
|
|
163
|
+
OUTPUT=$(./setup/aws/spawn-runner.sh | tee /dev/stderr)
|
|
164
|
+
PUBLIC_IP=$(echo "$OUTPUT" | grep "PUBLIC_IP=" | cut -d'=' -f2)
|
|
165
|
+
INSTANCE_ID=$(echo "$OUTPUT" | grep "INSTANCE_ID=" | cut -d'=' -f2)
|
|
166
|
+
echo "public-ip=$PUBLIC_IP" >> $GITHUB_OUTPUT
|
|
167
|
+
echo "instance-id=$INSTANCE_ID" >> $GITHUB_OUTPUT
|
|
168
|
+
env:
|
|
169
|
+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
170
|
+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
171
|
+
AWS_REGION: ${{ secrets.AWS_REGION }}
|
|
172
|
+
AWS_LAUNCH_TEMPLATE_ID: ${{ secrets.AWS_LAUNCH_TEMPLATE_ID }}
|
|
173
|
+
AMI_ID: ${{ secrets.AMI_ID }}
|
|
174
|
+
|
|
175
|
+
- name: Run Tests
|
|
176
|
+
run: npx vitest run
|
|
177
|
+
env:
|
|
178
|
+
TD_API_KEY: ${{ secrets.TD_API_KEY }}
|
|
179
|
+
TD_VM: ${{ steps.aws-setup.outputs.public-ip }}
|
|
180
|
+
|
|
181
|
+
- name: Shutdown AWS Instance
|
|
182
|
+
if: always()
|
|
183
|
+
run: |
|
|
184
|
+
aws ec2 terminate-instances \
|
|
185
|
+
--region ${{ secrets.AWS_REGION }} \
|
|
186
|
+
--instance-ids ${{ steps.aws-setup.outputs.instance-id }}
|
|
187
|
+
env:
|
|
188
|
+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
189
|
+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
190
|
+
AWS_REGION: ${{ secrets.AWS_REGION }}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Required GitHub Secrets
|
|
194
|
+
|
|
195
|
+
| Secret | Description | Example |
|
|
196
|
+
|--------|-------------|---------|
|
|
197
|
+
| `AWS_ACCESS_KEY_ID` | AWS access key | `AKIAIOSFODNN7EXAMPLE` |
|
|
198
|
+
| `AWS_SECRET_ACCESS_KEY` | AWS secret key | `wJalrXUtnFEMI/K7MDENG...` |
|
|
199
|
+
| `AWS_REGION` | AWS region | `us-east-2` |
|
|
200
|
+
| `AWS_LAUNCH_TEMPLATE_ID` | From CloudFormation output | `lt-07c53ce8349b958d1` |
|
|
201
|
+
| `AMI_ID` | TestDriver AMI ID | `ami-086b5b4b86d78987c` |
|
|
202
|
+
| `TD_API_KEY` | Your TestDriver API key | From [console.testdriver.ai](https://console.testdriver.ai) |
|
|
203
|
+
|
|
204
|
+
## AMI Customization
|
|
205
|
+
|
|
206
|
+
The TestDriver Golden Image comes pre-configured with:
|
|
207
|
+
|
|
208
|
+
- Windows Server with desktop environment
|
|
209
|
+
- VNC + web server for remote access
|
|
210
|
+
- Python, Node.js, Git
|
|
211
|
+
- TestDriver agent and dependencies
|
|
212
|
+
|
|
213
|
+
### Creating a Custom AMI
|
|
214
|
+
|
|
215
|
+
You can customize the AMI to include additional software or configurations:
|
|
216
|
+
|
|
217
|
+
<Steps>
|
|
218
|
+
<Step title="Connect via RDP">
|
|
219
|
+
Use the default credentials:
|
|
220
|
+
- **Username**: `testdriver`
|
|
221
|
+
- **Password**: `changemeABC123`
|
|
222
|
+
</Step>
|
|
223
|
+
|
|
224
|
+
<Step title="Change the Password">
|
|
225
|
+
**Critical**: Run the password rotation script immediately:
|
|
226
|
+
```powershell
|
|
227
|
+
C:\testdriver\RotateLocalPasswords.ps1
|
|
228
|
+
```
|
|
229
|
+
Save the new password securely.
|
|
230
|
+
</Step>
|
|
231
|
+
|
|
232
|
+
<Step title="Install Your Software">
|
|
233
|
+
Install any additional dependencies, configure settings, or modify the environment as needed.
|
|
234
|
+
</Step>
|
|
235
|
+
|
|
236
|
+
<Step title="Create New AMI">
|
|
237
|
+
Use the AWS console or CLI to create an AMI from your modified instance. Update your workflow to use the new AMI ID.
|
|
238
|
+
</Step>
|
|
239
|
+
</Steps>
|
|
240
|
+
|
|
241
|
+
<Warning>
|
|
242
|
+
**Security**: Never use the default password in production. Always rotate passwords before creating custom AMIs.
|
|
243
|
+
</Warning>
|
|
244
|
+
|
|
245
|
+
### Changing Screen Resolution
|
|
246
|
+
|
|
247
|
+
Set resolution via environment variable when spawning:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
export RESOLUTION=1920x1080
|
|
251
|
+
./setup/aws/spawn-runner.sh
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Or in a lifecycle provision script:
|
|
255
|
+
|
|
256
|
+
```yaml lifecycle/provision.yaml
|
|
257
|
+
version: 7.0.0
|
|
258
|
+
steps:
|
|
259
|
+
- prompt: set screen resolution
|
|
260
|
+
commands:
|
|
261
|
+
- command: exec
|
|
262
|
+
lang: pwsh
|
|
263
|
+
code: |
|
|
264
|
+
C:\testdriver\SetResolution.ps1 -Width 1920 -Height 1080
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Security Best Practices
|
|
268
|
+
|
|
269
|
+
### Network Security
|
|
270
|
+
|
|
271
|
+
- **Restrict CIDR blocks** — Only allow access from known IP ranges
|
|
272
|
+
- **Use VPC endpoints** — For private AWS service communication
|
|
273
|
+
- **Enable VPC Flow Logs** — For network monitoring
|
|
274
|
+
|
|
275
|
+
### AWS Authentication
|
|
276
|
+
|
|
277
|
+
Use OIDC instead of long-term credentials for GitHub Actions:
|
|
278
|
+
|
|
279
|
+
```yaml
|
|
280
|
+
permissions:
|
|
281
|
+
id-token: write
|
|
282
|
+
contents: read
|
|
283
|
+
|
|
284
|
+
steps:
|
|
285
|
+
- name: Configure AWS credentials
|
|
286
|
+
uses: aws-actions/configure-aws-credentials@v4
|
|
287
|
+
with:
|
|
288
|
+
role-to-assume: arn:aws:iam::123456789012:role/GitHubActionsRole
|
|
289
|
+
aws-region: us-east-2
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
See [GitHub's OIDC documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect) for setup instructions.
|
|
293
|
+
|
|
294
|
+
### Instance Security
|
|
295
|
+
|
|
296
|
+
- **Terminate immediately** after tests complete
|
|
297
|
+
- **Monitor costs** with AWS billing alerts
|
|
298
|
+
- **Use least-privilege IAM roles**
|
|
299
|
+
- **Enable CloudTrail** for audit logging
|
|
300
|
+
|
|
301
|
+
## Troubleshooting
|
|
302
|
+
|
|
303
|
+
### Instance Not Responding
|
|
304
|
+
|
|
305
|
+
- **Check security groups** — Verify required ports are open (RDP 3389, VNC 5900, TestDriver ports)
|
|
306
|
+
- **Verify status checks** — Ensure instance has passed AWS status checks
|
|
307
|
+
- **Check AMI compatibility** — Some instance types don't support certain AMIs
|
|
308
|
+
|
|
309
|
+
### Connection Timeouts
|
|
310
|
+
|
|
311
|
+
- Verify network connectivity from CI runner to instance
|
|
312
|
+
- Check VPC routing and internet gateway configuration
|
|
313
|
+
- Confirm instance is in the correct subnet
|
|
314
|
+
|
|
315
|
+
### AWS CLI Errors
|
|
316
|
+
|
|
317
|
+
- Validate credentials and permissions
|
|
318
|
+
- Check service quotas and limits
|
|
319
|
+
- Verify region consistency across all resources
|
|
320
|
+
|
|
321
|
+
## Getting Help
|
|
322
|
+
|
|
323
|
+
<CardGroup cols={2}>
|
|
324
|
+
<Card
|
|
325
|
+
title="Contact Support"
|
|
326
|
+
icon="envelope"
|
|
327
|
+
href="https://calendly.com/d/cq23-qyn-3v6/testdriver-ai-demo"
|
|
328
|
+
>
|
|
329
|
+
Get help with self-hosted setup and configuration
|
|
330
|
+
</Card>
|
|
331
|
+
<Card
|
|
332
|
+
title="Self-Hosted Overview"
|
|
333
|
+
icon="server"
|
|
334
|
+
href="/v7/self-hosted"
|
|
335
|
+
>
|
|
336
|
+
Learn more about self-hosted benefits and pricing
|
|
337
|
+
</Card>
|
|
338
|
+
</CardGroup>
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Caching Prompts"
|
|
3
|
+
description: "1.7x faster test execution with intelligent caching and optimization"
|
|
4
|
+
icon: "bolt"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
TestDriver is engineered for performance with intelligent caching that delivers up to **1.7x faster** test execution by skipping redundant AI vision analysis.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
```javascript
|
|
11
|
+
// First run: builds cache
|
|
12
|
+
await testdriver.find('submit button');
|
|
13
|
+
|
|
14
|
+
// Second run: exact match
|
|
15
|
+
await testdriver.find('submit button');
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Automatic Caching
|
|
19
|
+
|
|
20
|
+
Caching is enabled automatically with zero configuration. The cache key is computed from:
|
|
21
|
+
|
|
22
|
+
- **File hash**: SHA-256 hash of the test file contents
|
|
23
|
+
- **Selector prompt**: The exact text description passed to `find()`
|
|
24
|
+
- **Screenshot context**: Perceptual hash of the current screen state
|
|
25
|
+
- **Platform**: Operating system and browser version
|
|
26
|
+
|
|
27
|
+
When you modify your test file, the hash changes automatically, invalidating stale cache entries and ensuring fresh AI analysis with your updated test logic.
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
import { test } from 'vitest';
|
|
31
|
+
import { chrome } from 'testdriverai/presets';
|
|
32
|
+
|
|
33
|
+
test('auto-cached test', async (context) => {
|
|
34
|
+
const { testdriver } = await chrome(context, {
|
|
35
|
+
url: 'https://example.com'
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// First call: AI analyzes screen, saves to cache
|
|
39
|
+
await testdriver.find('More information link'); // 2.1s
|
|
40
|
+
|
|
41
|
+
// Second call: cache hit, instant response
|
|
42
|
+
await testdriver.find('More information link'); // 12ms ⚡
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Managing the Cache
|
|
47
|
+
|
|
48
|
+
You can clear the cache within the TestDriver console. There, you'll also find previews of cached elements, the input prompts, as well as analytics on cache hit rates.
|
|
49
|
+
|
|
50
|
+
<Card href="https://console.testdriver.ai/cache" title="TestDriver Cache" icon="database">
|
|
51
|
+
Manage and clear your test cache from the TestDriver console.
|
|
52
|
+
</Card>
|
|
53
|
+
|
|
54
|
+
## Debugging Cache Hits and Misses
|
|
55
|
+
|
|
56
|
+
You can track cache performance in your tests:
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
test('monitor cache performance', async (context) => {
|
|
60
|
+
const { testdriver } = await chrome(context, { url });
|
|
61
|
+
|
|
62
|
+
const element = await testdriver.find('submit button');
|
|
63
|
+
|
|
64
|
+
if (element.cacheHit) {
|
|
65
|
+
console.log('✅ Cache hit - instant response');
|
|
66
|
+
console.log('Strategy:', element.cacheStrategy); // 'exact', 'pixeldiff', or 'template'
|
|
67
|
+
console.log('Similarity:', `${(element.similarity * 100).toFixed(1)}%`);
|
|
68
|
+
console.log('Cache age:', element.cacheCreatedAt);
|
|
69
|
+
} else {
|
|
70
|
+
console.log('⏱️ Cache miss - AI analysis performed');
|
|
71
|
+
console.log('New cache entry created');
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Configuring the Cache
|
|
77
|
+
|
|
78
|
+
You can configure cache behavior globally when initializing TestDriver:
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
import { TestDriver } from 'testdriverai';
|
|
82
|
+
|
|
83
|
+
const testdriver = new TestDriver({
|
|
84
|
+
apiKey: process.env.TD_API_KEY,
|
|
85
|
+
cacheKey: 'my-test-suite', // cache-key for this instance
|
|
86
|
+
cacheDefaults: {
|
|
87
|
+
threshold: 0.05, // 95% similarity
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
It's also possible to override cache settings per `find()` call:
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
// Default: 95% similarity required
|
|
96
|
+
await testdriver.find('submit button');
|
|
97
|
+
|
|
98
|
+
// Explicit strict threshold
|
|
99
|
+
await testdriver.find('submit button', {
|
|
100
|
+
cacheThreshold: 0.01 // 99% similarity
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Caching with Variables
|
|
105
|
+
|
|
106
|
+
Custom cache keys prevent cache pollution when using variables in prompts, dramatically improving cache hit rates.
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
// ❌ Without cache key - creates new cache for each variable value
|
|
110
|
+
const email = 'user@example.com';
|
|
111
|
+
await testdriver.find(`input for ${email}`); // Cache miss every time
|
|
112
|
+
|
|
113
|
+
// ✅ With cache key - reuses cache regardless of variable
|
|
114
|
+
const email = 'user@example.com';
|
|
115
|
+
await testdriver.find(`input for ${email}`, {
|
|
116
|
+
cacheKey: 'email-input'
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Also useful for dynamic IDs, names, or other changing data
|
|
120
|
+
const orderId = generateOrderId();
|
|
121
|
+
await testdriver.find(`order ${orderId} status`, {
|
|
122
|
+
cacheKey: 'order-status' // Same cache for all orders
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|