testdriverai 7.8.0-test.8 → 7.8.0
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 +6 -5
- package/agent/lib/commands.js +3 -2
- package/agent/lib/http.js +144 -0
- package/agent/lib/sandbox.js +117 -102
- package/agent/lib/sdk.js +4 -2
- package/agent/lib/system.js +25 -65
- package/ai/skills/testdriver-mcp/SKILL.md +7 -0
- package/ai/skills/testdriver-running-tests/SKILL.md +1 -1
- package/docs/changelog.mdx +148 -8
- package/docs/docs.json +44 -37
- 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/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/{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/interfaces/logger.js +0 -12
- package/interfaces/vitest-plugin.mjs +3 -0
- package/lib/core/Dashcam.js +13 -16
- package/lib/environments.json +18 -0
- package/lib/resolve-channel.js +4 -3
- package/{examples → manual}/drag-and-drop.test.mjs +1 -1
- package/package.json +3 -3
- package/sdk.js +3 -3
- package/vitest.config.mjs +20 -32
- /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,333 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Provision"
|
|
3
|
+
sidebarTitle: "Provision"
|
|
4
|
+
description: "Launch browsers, desktop apps, and extensions in your sandbox"
|
|
5
|
+
icon: "rocket"
|
|
6
|
+
mode: "wide"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
The Provision API sets up applications in your sandbox before tests run. It handles downloading, installing, and launching browsers, desktop apps, VS Code, Chrome extensions, and more.
|
|
12
|
+
|
|
13
|
+
Access provision methods via `testdriver.provision.*`:
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
await testdriver.provision.chrome({ url: 'https://example.com' });
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
<Note>
|
|
20
|
+
When `reconnect: true` is set on the client, **all provision methods are skipped** since the application is assumed to already be running.
|
|
21
|
+
</Note>
|
|
22
|
+
|
|
23
|
+
## Methods
|
|
24
|
+
|
|
25
|
+
### chrome()
|
|
26
|
+
|
|
27
|
+
Launch Google Chrome with an optional URL.
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
await testdriver.provision.chrome(options?)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
<ParamField path="options" type="ProvisionChromeOptions">
|
|
34
|
+
<Expandable title="properties">
|
|
35
|
+
<ParamField path="url" type="string" default="http://testdriver-sandbox.vercel.app/">
|
|
36
|
+
URL to navigate to after launch.
|
|
37
|
+
</ParamField>
|
|
38
|
+
|
|
39
|
+
<ParamField path="maximized" type="boolean" default={true}>
|
|
40
|
+
Launch Chrome in maximized window mode.
|
|
41
|
+
</ParamField>
|
|
42
|
+
|
|
43
|
+
<ParamField path="guest" type="boolean" default={false}>
|
|
44
|
+
Launch Chrome in guest profile mode.
|
|
45
|
+
</ParamField>
|
|
46
|
+
</Expandable>
|
|
47
|
+
</ParamField>
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
// Basic
|
|
51
|
+
await testdriver.provision.chrome({ url: 'https://example.com' });
|
|
52
|
+
|
|
53
|
+
// With guest mode
|
|
54
|
+
await testdriver.provision.chrome({
|
|
55
|
+
url: 'https://example.com',
|
|
56
|
+
guest: true,
|
|
57
|
+
maximized: true,
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### chromeExtension()
|
|
62
|
+
|
|
63
|
+
Install and launch a Chrome extension. You can install from a local unpacked directory or from the Chrome Web Store by extension ID.
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
await testdriver.provision.chromeExtension(options)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
<ParamField path="options" type="ProvisionChromeExtensionOptions" required>
|
|
70
|
+
One of `extensionPath` or `extensionId` is required.
|
|
71
|
+
|
|
72
|
+
<Expandable title="properties">
|
|
73
|
+
<ParamField path="extensionPath" type="string">
|
|
74
|
+
Local path to an unpacked extension directory. The extension files are uploaded to the sandbox.
|
|
75
|
+
</ParamField>
|
|
76
|
+
|
|
77
|
+
<ParamField path="extensionId" type="string">
|
|
78
|
+
Chrome Web Store extension ID to install.
|
|
79
|
+
</ParamField>
|
|
80
|
+
|
|
81
|
+
<ParamField path="maximized" type="boolean" default={true}>
|
|
82
|
+
Launch Chrome in maximized window mode.
|
|
83
|
+
</ParamField>
|
|
84
|
+
</Expandable>
|
|
85
|
+
</ParamField>
|
|
86
|
+
|
|
87
|
+
```javascript
|
|
88
|
+
// From local directory
|
|
89
|
+
await testdriver.provision.chromeExtension({
|
|
90
|
+
extensionPath: './my-extension',
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// From Chrome Web Store
|
|
94
|
+
await testdriver.provision.chromeExtension({
|
|
95
|
+
extensionId: 'abcdefghijklmnop',
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### vscode()
|
|
100
|
+
|
|
101
|
+
Launch Visual Studio Code with an optional workspace and extensions.
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
await testdriver.provision.vscode(options?)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
<ParamField path="options" type="ProvisionVSCodeOptions">
|
|
108
|
+
<Expandable title="properties">
|
|
109
|
+
<ParamField path="workspace" type="string">
|
|
110
|
+
Path to a workspace folder or `.code-workspace` file to open.
|
|
111
|
+
</ParamField>
|
|
112
|
+
|
|
113
|
+
<ParamField path="extensions" type="string[]" default={[]}>
|
|
114
|
+
Array of VS Code extension IDs to install before launching.
|
|
115
|
+
</ParamField>
|
|
116
|
+
</Expandable>
|
|
117
|
+
</ParamField>
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
await testdriver.provision.vscode({
|
|
121
|
+
workspace: '/home/testdriver/project',
|
|
122
|
+
extensions: ['ms-python.python', 'esbenp.prettier-vscode'],
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### installer()
|
|
127
|
+
|
|
128
|
+
Download and run an application installer. Supports `.msi`, `.exe`, `.deb`, `.rpm`, `.appimage`, `.sh`, `.dmg`, and `.pkg` formats.
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
await testdriver.provision.installer(options)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
<ParamField path="options" type="ProvisionInstallerOptions" required>
|
|
135
|
+
<Expandable title="properties">
|
|
136
|
+
<ParamField path="url" type="string" required>
|
|
137
|
+
Download URL for the installer.
|
|
138
|
+
</ParamField>
|
|
139
|
+
|
|
140
|
+
<ParamField path="filename" type="string">
|
|
141
|
+
Override the auto-detected filename from the URL.
|
|
142
|
+
</ParamField>
|
|
143
|
+
|
|
144
|
+
<ParamField path="appName" type="string">
|
|
145
|
+
Application name to focus after installation completes.
|
|
146
|
+
</ParamField>
|
|
147
|
+
|
|
148
|
+
<ParamField path="launch" type="boolean" default={true}>
|
|
149
|
+
Whether to focus/launch the app after installation.
|
|
150
|
+
</ParamField>
|
|
151
|
+
</Expandable>
|
|
152
|
+
</ParamField>
|
|
153
|
+
|
|
154
|
+
**Behavior:**
|
|
155
|
+
- Downloads the installer from the URL
|
|
156
|
+
- Auto-detects the install method based on file extension
|
|
157
|
+
- Runs the appropriate install command (e.g., `msiexec` for `.msi`, `dpkg` for `.deb`)
|
|
158
|
+
- Optionally focuses the installed application
|
|
159
|
+
|
|
160
|
+
```javascript
|
|
161
|
+
// Windows MSI installer
|
|
162
|
+
await testdriver.provision.installer({
|
|
163
|
+
url: 'https://example.com/app-setup.msi',
|
|
164
|
+
appName: 'MyApp',
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Linux DEB package
|
|
168
|
+
await testdriver.provision.installer({
|
|
169
|
+
url: 'https://example.com/app.deb',
|
|
170
|
+
appName: 'MyApp',
|
|
171
|
+
launch: true,
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### electron()
|
|
176
|
+
|
|
177
|
+
Launch an Electron application.
|
|
178
|
+
|
|
179
|
+
```javascript
|
|
180
|
+
await testdriver.provision.electron(options)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
<ParamField path="options" type="ProvisionElectronOptions" required>
|
|
184
|
+
<Expandable title="properties">
|
|
185
|
+
<ParamField path="appPath" type="string" required>
|
|
186
|
+
Path to the Electron application directory or executable.
|
|
187
|
+
</ParamField>
|
|
188
|
+
|
|
189
|
+
<ParamField path="args" type="string[]" default={[]}>
|
|
190
|
+
Additional command-line arguments to pass to the Electron app.
|
|
191
|
+
</ParamField>
|
|
192
|
+
</Expandable>
|
|
193
|
+
</ParamField>
|
|
194
|
+
|
|
195
|
+
```javascript
|
|
196
|
+
await testdriver.provision.electron({
|
|
197
|
+
appPath: '/home/testdriver/my-electron-app',
|
|
198
|
+
args: ['--no-sandbox'],
|
|
199
|
+
});
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### dashcam()
|
|
203
|
+
|
|
204
|
+
Start Dashcam recording with custom options. Usually called automatically by other provision methods, but can be called directly for custom configurations.
|
|
205
|
+
|
|
206
|
+
```javascript
|
|
207
|
+
await testdriver.provision.dashcam(options?)
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
<ParamField path="options" type="ProvisionDashcamOptions">
|
|
211
|
+
<Expandable title="properties">
|
|
212
|
+
<ParamField path="logPath" type="string">
|
|
213
|
+
Path to the TestDriver log file. Defaults to `/tmp/testdriver.log` (Linux) or `C:\Users\testdriver\testdriver.log` (Windows).
|
|
214
|
+
</ParamField>
|
|
215
|
+
|
|
216
|
+
<ParamField path="logName" type="string" default="TestDriver Log">
|
|
217
|
+
Display name for the log file in the Dashcam replay.
|
|
218
|
+
</ParamField>
|
|
219
|
+
|
|
220
|
+
<ParamField path="webLogs" type="boolean" default={true}>
|
|
221
|
+
Enable web traffic log capture.
|
|
222
|
+
</ParamField>
|
|
223
|
+
|
|
224
|
+
<ParamField path="title" type="string">
|
|
225
|
+
Recording title for the Dashcam session.
|
|
226
|
+
</ParamField>
|
|
227
|
+
</Expandable>
|
|
228
|
+
</ParamField>
|
|
229
|
+
|
|
230
|
+
```javascript
|
|
231
|
+
await testdriver.provision.dashcam({
|
|
232
|
+
title: 'Login Flow Test',
|
|
233
|
+
logPath: '/tmp/my-app.log',
|
|
234
|
+
logName: 'Application Log',
|
|
235
|
+
webLogs: true,
|
|
236
|
+
});
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Reconnect Behavior
|
|
240
|
+
|
|
241
|
+
When `reconnect: true` is set on the client, all provision methods are wrapped in a Proxy that intercepts calls and skips them silently. This is because when reconnecting to an existing sandbox, the applications are already running.
|
|
242
|
+
|
|
243
|
+
```javascript
|
|
244
|
+
const testdriver = new TestDriver({
|
|
245
|
+
reconnect: true,
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
await testdriver.ready();
|
|
249
|
+
|
|
250
|
+
// These calls are silently skipped:
|
|
251
|
+
await testdriver.provision.chrome({ url: 'https://example.com' });
|
|
252
|
+
await testdriver.provision.dashcam();
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Types
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
interface ProvisionChromeOptions {
|
|
259
|
+
url?: string; // Default: "http://testdriver-sandbox.vercel.app/"
|
|
260
|
+
maximized?: boolean; // Default: true
|
|
261
|
+
guest?: boolean; // Default: false
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
interface ProvisionChromeExtensionOptions {
|
|
265
|
+
extensionPath?: string; // Local unpacked extension path
|
|
266
|
+
extensionId?: string; // Chrome Web Store ID
|
|
267
|
+
maximized?: boolean; // Default: true
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
interface ProvisionVSCodeOptions {
|
|
271
|
+
workspace?: string; // Workspace path
|
|
272
|
+
extensions?: string[]; // Extension IDs to install
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
interface ProvisionInstallerOptions {
|
|
276
|
+
url: string; // Download URL (required)
|
|
277
|
+
filename?: string; // Override filename
|
|
278
|
+
appName?: string; // App name to focus
|
|
279
|
+
launch?: boolean; // Default: true
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
interface ProvisionElectronOptions {
|
|
283
|
+
appPath: string; // Path to Electron app (required)
|
|
284
|
+
args?: string[]; // Additional args
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
interface ProvisionDashcamOptions {
|
|
288
|
+
logPath?: string; // Log file path
|
|
289
|
+
logName?: string; // Default: "TestDriver Log"
|
|
290
|
+
webLogs?: boolean; // Default: true
|
|
291
|
+
title?: string; // Recording title
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Complete Example
|
|
296
|
+
|
|
297
|
+
```javascript
|
|
298
|
+
import { describe, it, beforeAll, afterAll } from 'vitest';
|
|
299
|
+
import TestDriver from 'testdriverai';
|
|
300
|
+
|
|
301
|
+
describe('Chrome Extension Test', () => {
|
|
302
|
+
let testdriver;
|
|
303
|
+
|
|
304
|
+
beforeAll(async () => {
|
|
305
|
+
testdriver = new TestDriver({
|
|
306
|
+
os: 'linux',
|
|
307
|
+
resolution: '1920x1080',
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
await testdriver.ready();
|
|
311
|
+
|
|
312
|
+
// Install extension and open Chrome
|
|
313
|
+
await testdriver.provision.chromeExtension({
|
|
314
|
+
extensionPath: './my-extension',
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
// Start Dashcam with custom logs
|
|
318
|
+
await testdriver.provision.dashcam({
|
|
319
|
+
title: 'Extension Test',
|
|
320
|
+
webLogs: true,
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
afterAll(async () => {
|
|
325
|
+
await testdriver.disconnect();
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('tests the extension popup', async () => {
|
|
329
|
+
await testdriver.find('extension icon').click();
|
|
330
|
+
await testdriver.find('popup content').click();
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
```
|
package/docs/v7/quickstart.mdx
CHANGED
|
@@ -10,7 +10,7 @@ TestDriver makes it easy to write automated computer-use tests for web browsers,
|
|
|
10
10
|
<Tip><a href="https://discord.com/invite/cWDFW8DzPm" target="_blank" rel="noreferrer">Join our Discord</a> if you have any questions or need help getting started!</Tip>
|
|
11
11
|
|
|
12
12
|
<Tabs>
|
|
13
|
-
<Tab title="
|
|
13
|
+
<Tab title="CLI" icon="terminal">
|
|
14
14
|
|
|
15
15
|
Get started quickly with the TestDriver CLI.
|
|
16
16
|
|
|
@@ -40,7 +40,35 @@ TestDriver makes it easy to write automated computer-use tests for web browsers,
|
|
|
40
40
|
</Step>
|
|
41
41
|
</Steps>
|
|
42
42
|
</Tab>
|
|
43
|
-
<Tab title="
|
|
43
|
+
<Tab title="GitHub Copilot" icon="github">
|
|
44
|
+
|
|
45
|
+
Use the TestDriver VS Code extension with GitHub Copilot for an AI-powered testing workflow.
|
|
46
|
+
|
|
47
|
+
<Card
|
|
48
|
+
title="Install TestDriver for VS Code"
|
|
49
|
+
icon="/images/content/extension/vscode.svg"
|
|
50
|
+
href="vscode:extension/testdriver.testdriver"
|
|
51
|
+
arrow
|
|
52
|
+
horizontal
|
|
53
|
+
>
|
|
54
|
+
</Card>
|
|
55
|
+
|
|
56
|
+
The extension provides one-click sign-in, project initialization, a live preview panel for watching tests execute, and MCP server configuration for GitHub Copilot.
|
|
57
|
+
|
|
58
|
+
Once installed, follow the full setup guide to configure MCP and start building tests with AI assistance:
|
|
59
|
+
|
|
60
|
+
<Card
|
|
61
|
+
title="VS Code + Copilot Setup Guide"
|
|
62
|
+
icon="arrow-right"
|
|
63
|
+
href="/v7/copilot/setup"
|
|
64
|
+
arrow
|
|
65
|
+
horizontal
|
|
66
|
+
>
|
|
67
|
+
Sign in, initialize your project, and configure MCP for GitHub Copilot.
|
|
68
|
+
</Card>
|
|
69
|
+
|
|
70
|
+
</Tab>
|
|
71
|
+
<Tab title="Manual" icon="wrench">
|
|
44
72
|
|
|
45
73
|
Install TestDriver and manually create the files yourself.
|
|
46
74
|
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Redraw"
|
|
3
|
+
sidebarTitle: "Redraw"
|
|
4
|
+
description: "Wait for the screen to stabilize after interactions"
|
|
5
|
+
icon: "rotate"
|
|
6
|
+
mode: "wide"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
The redraw system waits for the screen to stabilize after an interaction before continuing. It detects when animations, page loads, and network requests have settled, preventing actions from being performed on a changing screen.
|
|
12
|
+
|
|
13
|
+
<Note>
|
|
14
|
+
**Redraw is disabled by default since v7.3.** Enable it explicitly if your tests interact with applications that have significant animations or loading states.
|
|
15
|
+
</Note>
|
|
16
|
+
|
|
17
|
+
## How It Works
|
|
18
|
+
|
|
19
|
+
Redraw uses a **two-phase detection** approach:
|
|
20
|
+
|
|
21
|
+
1. **Change Detection** — Compare the current frame to the initial screenshot taken right after the action. If the pixel diff exceeds 0.1%, the screen has changed.
|
|
22
|
+
2. **Stability Detection** — Compare consecutive frames using z-score analysis. When the diff between frames drops below 0.1% or the z-score is negative (current diff is below average), the screen has settled.
|
|
23
|
+
|
|
24
|
+
The screen is considered **settled** when both phases complete: the screen changed from the initial state AND consecutive frames are now stable.
|
|
25
|
+
|
|
26
|
+
```mermaid
|
|
27
|
+
flowchart TD
|
|
28
|
+
A[Action performed] --> B{Phase 1: Change Detection\ndiffFromInitial > 0.1%?}
|
|
29
|
+
B -- "Yes (screen changed)" --> C{Phase 2: Stability\nz-score < 0 or\ndiffPercent < 0.1%?}
|
|
30
|
+
C -- "Yes (frames stable)" --> D[Screen settled ✓]
|
|
31
|
+
B -- "No (waiting...)" --> B
|
|
32
|
+
C -- "No (waiting...)" --> C
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Polling
|
|
36
|
+
|
|
37
|
+
The system polls at **500ms intervals**, comparing screenshot frames. This reduces WebSocket traffic while still providing responsive detection.
|
|
38
|
+
|
|
39
|
+
### Pixel Comparison
|
|
40
|
+
|
|
41
|
+
Uses [pixelmatch](https://github.com/mapbox/pixelmatch) for per-pixel comparison with a threshold of `0.1` for pixel sensitivity. A frame diff above **0.1% of total pixels** indicates the screen has changed.
|
|
42
|
+
|
|
43
|
+
### Z-Score Analysis
|
|
44
|
+
|
|
45
|
+
Screen stability uses statistical analysis of the last **10 measurements**:
|
|
46
|
+
|
|
47
|
+
1. Calculate the mean and standard deviation of consecutive frame diffs
|
|
48
|
+
2. Compute the z-score: `(currentDiff - mean) / stddev`
|
|
49
|
+
3. Screen is stable when `diffPercent < 0.1%` or `z-score < 0` (current diff is below the average)
|
|
50
|
+
|
|
51
|
+
This approach adapts to the specific animation patterns of your application rather than using a fixed threshold.
|
|
52
|
+
|
|
53
|
+
## Per-Command Timeouts
|
|
54
|
+
|
|
55
|
+
Each command type has a specific redraw timeout:
|
|
56
|
+
|
|
57
|
+
| Command | Timeout | Reason |
|
|
58
|
+
|---------|---------|--------|
|
|
59
|
+
| `click` | 5000ms | Page navigations, modal openings |
|
|
60
|
+
| `hover` (within click) | 5000ms | Same as click |
|
|
61
|
+
| `hover` (standalone) | 2500ms | Tooltip animations |
|
|
62
|
+
| `scroll` | 5000ms | Lazy-loaded content |
|
|
63
|
+
| `type` | 5000ms | Autocomplete, validation |
|
|
64
|
+
| `pressKeys` | 5000ms | Keyboard shortcuts may trigger changes |
|
|
65
|
+
| `focusApplication` | 1000ms | Window focus animations |
|
|
66
|
+
|
|
67
|
+
If the timeout is reached before the screen settles, the command continues anyway. The timeout event is available via the `redraw:complete` event.
|
|
68
|
+
|
|
69
|
+
## Configuration
|
|
70
|
+
|
|
71
|
+
### Constructor Options
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
const testdriver = new TestDriver({
|
|
75
|
+
// Shorthand: enable/disable
|
|
76
|
+
redraw: true, // enable with defaults
|
|
77
|
+
redraw: false, // disable (default since v7.3)
|
|
78
|
+
|
|
79
|
+
// Full configuration
|
|
80
|
+
redraw: {
|
|
81
|
+
enabled: true,
|
|
82
|
+
screenRedraw: true, // enable screen pixel diff detection
|
|
83
|
+
networkMonitor: false, // enable network settling detection
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
<ParamField path="redraw" type="RedrawConfig | boolean" default={false}>
|
|
89
|
+
Redraw configuration. Pass `true`/`false` for shorthand, or an object for fine-grained control.
|
|
90
|
+
|
|
91
|
+
<Expandable title="properties">
|
|
92
|
+
<ParamField path="enabled" type="boolean" default={false}>
|
|
93
|
+
Enable or disable the redraw system. Default changed to `false` in v7.3.
|
|
94
|
+
</ParamField>
|
|
95
|
+
|
|
96
|
+
<ParamField path="screenRedraw" type="boolean" default={true}>
|
|
97
|
+
Enable pixel-diff-based screen change detection. If both `screenRedraw` and `networkMonitor` are `false`, redraw auto-disables.
|
|
98
|
+
</ParamField>
|
|
99
|
+
|
|
100
|
+
<ParamField path="networkMonitor" type="boolean" default={false}>
|
|
101
|
+
Enable network traffic monitoring for settling detection. Monitors WebSocket traffic on the sandbox to detect when network activity subsides.
|
|
102
|
+
</ParamField>
|
|
103
|
+
</Expandable>
|
|
104
|
+
</ParamField>
|
|
105
|
+
|
|
106
|
+
### Per-Command Override
|
|
107
|
+
|
|
108
|
+
Override redraw settings for individual commands:
|
|
109
|
+
|
|
110
|
+
```javascript
|
|
111
|
+
// Enable redraw for a specific click
|
|
112
|
+
await testdriver.find('load more').click({
|
|
113
|
+
redraw: { enabled: true },
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Disable redraw for a fast interaction
|
|
117
|
+
await testdriver.find('checkbox').click({
|
|
118
|
+
redraw: false,
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Network Settling
|
|
123
|
+
|
|
124
|
+
When `networkMonitor` is enabled, the system also monitors sandbox network traffic:
|
|
125
|
+
|
|
126
|
+
- Polls for `totalBytesReceived` and `totalBytesSent` from the sandbox
|
|
127
|
+
- Keeps the last **60 measurements**
|
|
128
|
+
- Calculates z-scores for both RX and TX byte rates
|
|
129
|
+
- Network is **settled** when both RX and TX z-scores are negative (traffic is below average)
|
|
130
|
+
- Has a **10-second timeout** for network polling
|
|
131
|
+
- Non-critical: network errors are logged but never throw
|
|
132
|
+
|
|
133
|
+
The final settling condition requires **both** screen AND network to be settled (when both are enabled).
|
|
134
|
+
|
|
135
|
+
## Events
|
|
136
|
+
|
|
137
|
+
The redraw system emits events through the SDK emitter. See [Events](/v7/events) for the full event reference.
|
|
138
|
+
|
|
139
|
+
| Event | Description |
|
|
140
|
+
|---|---|
|
|
141
|
+
| `redraw:status` | Emitted on each poll with current screen diff, network stats, and timeout info |
|
|
142
|
+
| `redraw:complete` | Emitted when redraw resolves (settled or timed out) |
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
testdriver.emitter.on('redraw:status', (status) => {
|
|
146
|
+
console.log(`Screen: ${status.redraw.text}`);
|
|
147
|
+
console.log(`Network: ${status.network.text}`);
|
|
148
|
+
console.log(`Timeout: ${status.timeout.text}`);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
testdriver.emitter.on('redraw:complete', (result) => {
|
|
152
|
+
if (result.isTimeout) {
|
|
153
|
+
console.warn(`Redraw timed out after ${result.timeElapsed}ms`);
|
|
154
|
+
} else {
|
|
155
|
+
console.log(`Screen settled in ${result.timeElapsed}ms`);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## When to Use Redraw
|
|
161
|
+
|
|
162
|
+
**Enable redraw when:**
|
|
163
|
+
- Testing single-page applications (SPAs) with route transitions
|
|
164
|
+
- Interacting with pages that lazy-load content on scroll
|
|
165
|
+
- Clicking buttons that trigger animations or modals
|
|
166
|
+
- Testing apps with significant network-driven UI updates
|
|
167
|
+
|
|
168
|
+
**Keep redraw disabled when:**
|
|
169
|
+
- Tests are already stable without it
|
|
170
|
+
- You want faster test execution
|
|
171
|
+
- Your application has minimal animations
|
|
172
|
+
- You're using explicit waits or assertions instead
|
|
173
|
+
|
|
174
|
+
## Types
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
interface RedrawConfig {
|
|
178
|
+
enabled?: boolean; // Default: false (since v7.3)
|
|
179
|
+
screenRedraw?: boolean; // Default: true
|
|
180
|
+
networkMonitor?: boolean; // Default: false
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
interface RedrawStatusEvent {
|
|
184
|
+
redraw: {
|
|
185
|
+
enabled: boolean;
|
|
186
|
+
settled: boolean;
|
|
187
|
+
hasChangedFromInitial: boolean;
|
|
188
|
+
consecutiveFramesStable: number;
|
|
189
|
+
diffFromInitial: number;
|
|
190
|
+
diffFromLast: number;
|
|
191
|
+
text: string;
|
|
192
|
+
};
|
|
193
|
+
network: {
|
|
194
|
+
enabled: boolean;
|
|
195
|
+
settled: boolean;
|
|
196
|
+
rxBytes: number;
|
|
197
|
+
txBytes: number;
|
|
198
|
+
text: string;
|
|
199
|
+
};
|
|
200
|
+
timeout: {
|
|
201
|
+
isTimeout: boolean;
|
|
202
|
+
elapsed: number;
|
|
203
|
+
max: number;
|
|
204
|
+
text: string;
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
interface RedrawCompleteEvent {
|
|
209
|
+
screenSettled: boolean;
|
|
210
|
+
hasChangedFromInitial: boolean;
|
|
211
|
+
consecutiveFramesStable: number;
|
|
212
|
+
networkSettled: boolean;
|
|
213
|
+
isTimeout: boolean;
|
|
214
|
+
timeElapsed: number;
|
|
215
|
+
}
|
|
216
|
+
```
|