testdriverai 7.2.3 → 7.2.10
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/publish.yaml +15 -7
- package/.github/workflows/testdriver.yml +163 -0
- package/.testdriver/last-sandbox +7 -0
- package/agent/events.js +1 -0
- package/agent/index.js +99 -163
- package/agent/lib/sandbox.js +11 -1
- package/agents.md +393 -0
- package/bin/testdriverai.js +8 -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/debugger/index.html +37 -0
- package/docs/docs.json +93 -125
- package/docs/v7/_drafts/architecture.mdx +1 -26
- 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/_drafts/quick-start-test-recording.mdx +0 -1
- package/docs/v7/{features → _drafts}/scalable.mdx +126 -4
- package/docs/v7/_drafts/screenshot.mdx +155 -0
- package/docs/v7/_drafts/test-recording.mdx +0 -6
- package/docs/v7/_drafts/writing-tests.mdx +25 -0
- package/docs/v7/{api/act.mdx → ai.mdx} +28 -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/doubleClick.mdx → double-click.mdx} +5 -5
- package/docs/v7/enterprise.mdx +135 -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 +32 -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/interfaces/cli/commands/init.js +33 -19
- package/interfaces/cli/lib/base.js +24 -0
- package/interfaces/cli.js +8 -1
- package/interfaces/logger.js +8 -3
- package/interfaces/vitest-plugin.mjs +16 -71
- package/lib/sentry.js +343 -0
- package/lib/vitest/hooks.mjs +81 -81
- package/package.json +4 -3
- package/sdk-log-formatter.js +41 -0
- package/sdk.d.ts +22 -9
- package/sdk.js +344 -100
- package/test/manual/reconnect-provision.test.mjs +49 -0
- package/test/manual/reconnect-signin.test.mjs +41 -0
- package/test/testdriver/act.test.mjs +30 -0
- package/test/testdriver/ai.test.mjs +30 -0
- package/test/testdriver/assert.test.mjs +1 -1
- package/test/testdriver/hover-text.test.mjs +1 -1
- package/test/testdriver/setup/testHelpers.mjs +8 -119
- package/test/testdriver/windows-installer.test.mjs +61 -0
- package/tests/example.test.js +33 -0
- package/tests/login.js +28 -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 +3 -1
- package/agent/lib/cache.js +0 -142
- package/docs/v7/api/assertions.mdx +0 -403
- 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/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
- /package/docs/v7/{api/dashcam.mdx → dashcam.mdx} +0 -0
- /package/docs/v7/{api/elements.mdx → elements.mdx} +0 -0
- /package/docs/v7/{api/sandbox.mdx → sandbox.mdx} +0 -0
|
@@ -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
|
+
|