@testdriverai/agent 7.11.240-test → 7.11.241-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 (52) hide show
  1. package/ai/skills/testdriver-agent/SKILL.md +174 -91
  2. package/ai/skills/testdriver-assert/SKILL.md +73 -269
  3. package/ai/skills/testdriver-aws-setup/SKILL.md +194 -312
  4. package/ai/skills/testdriver-bring-your-own-machine/SKILL.md +137 -204
  5. package/ai/skills/testdriver-cache/SKILL.md +142 -149
  6. package/ai/skills/testdriver-caching/SKILL.md +97 -87
  7. package/ai/skills/testdriver-captcha/SKILL.md +126 -111
  8. package/ai/skills/testdriver-ci-cd/SKILL.md +153 -542
  9. package/ai/skills/testdriver-click/SKILL.md +74 -229
  10. package/ai/skills/testdriver-client/SKILL.md +175 -229
  11. package/ai/skills/testdriver-customizing-devices/SKILL.md +72 -250
  12. package/ai/skills/testdriver-dashcam/SKILL.md +71 -404
  13. package/ai/skills/testdriver-debugging-with-screenshots/SKILL.md +103 -369
  14. package/ai/skills/testdriver-double-click/SKILL.md +46 -67
  15. package/ai/skills/testdriver-errors/SKILL.md +102 -176
  16. package/ai/skills/testdriver-events/SKILL.md +170 -327
  17. package/ai/skills/testdriver-exec/SKILL.md +92 -256
  18. package/ai/skills/testdriver-extract/SKILL.md +69 -170
  19. package/ai/skills/testdriver-find/SKILL.md +140 -736
  20. package/ai/skills/testdriver-focus-application/SKILL.md +69 -246
  21. package/ai/skills/testdriver-generating-tests/SKILL.md +102 -136
  22. package/ai/skills/testdriver-hosted/SKILL.md +79 -143
  23. package/ai/skills/testdriver-hover/SKILL.md +62 -235
  24. package/ai/skills/testdriver-locating-elements/SKILL.md +71 -366
  25. package/ai/skills/testdriver-making-assertions/SKILL.md +114 -72
  26. package/ai/skills/testdriver-mcp-setup/SKILL.md +79 -62
  27. package/ai/skills/testdriver-mouse-down/SKILL.md +46 -124
  28. package/ai/skills/testdriver-mouse-up/SKILL.md +45 -128
  29. package/ai/skills/testdriver-options/SKILL.md +73 -46
  30. package/ai/skills/testdriver-parse/SKILL.md +95 -184
  31. package/ai/skills/testdriver-performing-actions/SKILL.md +101 -91
  32. package/ai/skills/testdriver-press-keys/SKILL.md +59 -299
  33. package/ai/skills/testdriver-provision/SKILL.md +135 -179
  34. package/ai/skills/testdriver-quickstart/SKILL.md +24 -8
  35. package/ai/skills/testdriver-quickstart-claude/SKILL.md +84 -0
  36. package/ai/skills/testdriver-quickstart-github/SKILL.md +62 -32
  37. package/ai/skills/testdriver-quickstart-manual/SKILL.md +59 -32
  38. package/ai/skills/testdriver-quickstart-vscode/SKILL.md +96 -0
  39. package/ai/skills/testdriver-redraw/SKILL.md +100 -164
  40. package/ai/skills/testdriver-reusable-code/SKILL.md +95 -199
  41. package/ai/skills/testdriver-right-click/SKILL.md +45 -88
  42. package/ai/skills/testdriver-screenshot/SKILL.md +47 -201
  43. package/ai/skills/testdriver-screenshots/SKILL.md +86 -136
  44. package/ai/skills/testdriver-scroll/SKILL.md +71 -154
  45. package/ai/skills/testdriver-secrets/SKILL.md +94 -90
  46. package/ai/skills/testdriver-self-hosted/SKILL.md +82 -140
  47. package/ai/skills/testdriver-test-results-json/SKILL.md +165 -202
  48. package/ai/skills/testdriver-type/SKILL.md +56 -304
  49. package/ai/skills/testdriver-variables/SKILL.md +119 -80
  50. package/ai/skills/testdriver-wait/SKILL.md +31 -29
  51. package/ai/skills/testdriver-what-is-testdriver/SKILL.md +80 -32
  52. package/package.json +1 -1
@@ -1,214 +1,150 @@
1
1
  ---
2
2
  name: testdriver:redraw
3
- description: Wait for the screen to stabilize after interactions
3
+ description: Make actions wait until the screen stops changing before the next step runs.
4
4
  ---
5
5
  <!-- Generated from redraw.mdx. DO NOT EDIT. -->
6
6
 
7
- ## Overview
7
+ Redraw detection makes each action wait until the screen has changed and then stopped changing.
8
8
 
9
- The redraw system waits for the screen to become stable after an interaction. Then it continues. It finds when animations, page loads, and network requests are complete. This stops actions on a screen that changes.
9
+ - Use it for apps with animations, page transitions, or content that loads after a click.
10
+ - It's off by default. Without it, the next command runs as soon as the action is sent.
11
+ - It can also wait for network traffic in the sandbox to die down.
10
12
 
11
- <Note>
12
- **Redraw is disabled by default from v7.3.** Enable it if your tests interact with applications that have many animations or load states.
13
- </Note>
13
+ ## Turn it on
14
14
 
15
- ## How It Works
15
+ Pass `redraw: true` when you create the client:
16
16
 
17
- Redraw uses a **two-phase detection** method:
17
+ ```javascript tests/search.test.mjs
18
+ import { describe, expect, it } from 'vitest';
19
+ import { TestDriver } from 'testdriverai/vitest/hooks';
18
20
 
19
- 1. **Change Detection**. TestDriver compares the present frame to the first screenshot from after the action. If the pixel diff is more than 0.1%, the screen changed.
20
- 2. **Stability Detection** — TestDriver compares frames that come after each other with z-score analysis. When the diff between frames is less than 0.1%, or the z-score is negative (the present diff is less than the average), the screen is complete.
21
+ describe('Search', () => {
22
+ it('shows results after searching', async (context) => {
23
+ const testdriver = TestDriver(context, { redraw: true });
24
+ await testdriver.provision.chrome({ url: 'https://testdriver-sandbox.vercel.app/login' });
21
25
 
22
- The screen is **complete** when both phases finish: the screen changed from the first state AND the frames that come after each other are now stable.
26
+ // With redraw on, click() returns once the error message has finished drawing
27
+ await testdriver.find('Sign in button below the password field').click();
23
28
 
24
- ```mermaid
25
- flowchart TD
26
- A[Action performed] --> B{Phase 1: Change Detection\ndiffFromInitial > 0.1%?}
27
- B -- "Yes (screen changed)" --> C{Phase 2: Stability\nz-score < 0 or\ndiffPercent < 0.1%?}
28
- C -- "Yes (frames stable)" --> D[Screen settled ✓]
29
- B -- "No (waiting...)" --> B
30
- C -- "No (waiting...)" --> C
29
+ const result = await testdriver.assert('an error says the fields are required');
30
+ expect(result).toBe(true);
31
+ });
32
+ });
31
33
  ```
32
34
 
33
- ### Polling
34
-
35
- The system polls at **500ms intervals**, comparing screenshot frames. This reduces WebSocket traffic while still providing responsive detection.
36
-
37
- ### Pixel Comparison
38
-
39
- 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.
40
-
41
- ### Z-Score Analysis
35
+ Every click, hover, type, key press, scroll, and `focusApplication()` call now waits for the screen to settle.
42
36
 
43
- Screen stability uses statistical analysis of the last **10 measurements**:
37
+ ## What it waits for
44
38
 
45
- 1. Calculate the mean and standard deviation of consecutive frame diffs
46
- 2. Compute the z-score: `(currentDiff - mean) / stddev`
47
- 3. Screen is stable when `diffPercent < 0.1%` or `z-score < 0` (current diff is below the average)
39
+ TestDriver takes a small screenshot right before the action, then one every 500 ms after it. The screen counts as settled when both of these are true:
48
40
 
49
- This approach adapts to the specific animation patterns of your application rather than using a fixed threshold.
41
+ 1. **The screen changed.** A frame differs from the "before" screenshot by more than 0.1% of its pixels.
42
+ 2. **The screen stopped changing.** The latest frame differs from the previous one by less than 0.1%, or by less than the average of the last 10 frames.
50
43
 
51
- ## Per-Command Timeouts
44
+ If the screen doesn't settle in time, the command carries on anyway. It doesn't throw.
52
45
 
53
- Each command type has a specific redraw timeout:
46
+ | Command | Waits at most |
47
+ | --- | --- |
48
+ | `click()`, `doubleClick()`, `rightClick()`, `mouseDown()`, `mouseUp()` | 5 s |
49
+ | `hover()` | 2.5 s |
50
+ | `type()` | 5 s |
51
+ | `pressKeys()` | 5 s |
52
+ | `scroll()` | 5 s |
53
+ | `focusApplication()` | 1 s |
54
54
 
55
- | Command | Timeout | Reason |
56
- |---------|---------|--------|
57
- | `click` | 5000ms | Page navigations, modal openings |
58
- | `hover` (within click) | 5000ms | Same as click |
59
- | `hover` (standalone) | 2500ms | Tooltip animations |
60
- | `scroll` | 5000ms | Lazy-loaded content |
61
- | `type` | 5000ms | Autocomplete, validation |
62
- | `pressKeys` | 5000ms | Keyboard shortcuts may trigger changes |
63
- | `focusApplication` | 1000ms | Window focus animations |
55
+ <Warning>
56
+ An action that doesn't change the screen never meets the first condition. It waits the full timeout, such as 5 seconds for a click. Turn redraw off for those commands (see below) or leave it off and use [`wait()`](/wait) where you need it.
57
+ </Warning>
64
58
 
65
- If the timeout is reached before the screen settles, the command continues anyway. The timeout event is available via the `redraw:complete` event.
59
+ ## Wait for network traffic too
66
60
 
67
- ## Configuration
68
-
69
- ### Constructor Options
61
+ Set `thresholds.network` to also wait until the sandbox's network traffic drops below its recent average:
70
62
 
71
63
  ```javascript
72
- const testdriver = new TestDriver({
73
- // Shorthand: enable/disable
74
- redraw: true, // enable with defaults
75
- redraw: false, // disable (default since v7.3)
76
-
77
- // Full configuration
78
- redraw: {
79
- enabled: true,
80
- screenRedraw: true, // enable screen pixel diff detection
81
- networkMonitor: false, // enable network settling detection
82
- },
64
+ const testdriver = TestDriver(context, {
65
+ redraw: { thresholds: { network: true } },
83
66
  });
84
67
  ```
85
68
 
86
- <ParamField path="redraw" type="RedrawConfig | boolean" default={false}>
87
- Redraw configuration. Pass `true`/`false` for shorthand, or an object for fine-grained control.
69
+ TestDriver then waits for both the screen and the network to settle, within the same timeouts.
70
+
71
+ To wait for the network only, turn off the screen check with `thresholds: { screen: false, network: true }`.
72
+
73
+ ## Options
74
+
75
+ <ParamField path="redraw" type="boolean | object" default="false">
76
+ `true` turns on screen detection. Pass an object to choose what to wait for.
88
77
 
89
78
  <Expandable title="properties">
90
- <ParamField path="enabled" type="boolean" default={false}>
91
- Enable or disable the redraw system. Default changed to `false` in v7.3.
79
+ <ParamField path="enabled" type="boolean" default="true">
80
+ Whether redraw detection is on when you pass an object.
92
81
  </ParamField>
93
-
94
- <ParamField path="screenRedraw" type="boolean" default={true}>
95
- Enable pixel-diff-based screen change detection. If both `screenRedraw` and `networkMonitor` are `false`, redraw auto-disables.
96
- </ParamField>
97
-
98
- <ParamField path="networkMonitor" type="boolean" default={false}>
99
- Enable network traffic monitoring for settling detection. Monitors WebSocket traffic on the sandbox to detect when network activity subsides.
82
+ <ParamField path="thresholds" type="object">
83
+ <Expandable title="properties">
84
+ <ParamField path="screen" type="number | false">
85
+ Set to `false` to skip the screen check. Any other value leaves it on. The 0.1% change threshold is fixed.
86
+ </ParamField>
87
+ <ParamField path="network" type="boolean" default="false">
88
+ Also wait for network traffic in the sandbox to settle.
89
+ </ParamField>
90
+ </Expandable>
100
91
  </ParamField>
101
92
  </Expandable>
102
93
  </ParamField>
103
94
 
104
- ### Per-Command Override
95
+ <Note>
96
+ Older tests may use `redrawThreshold`, or `diffThreshold`, `screenRedraw`, and `networkMonitor` inside `redraw`. They still work, but are deprecated. Use `redraw` with `thresholds` instead.
97
+ </Note>
98
+
99
+ ## Override it for one command
105
100
 
106
- Override redraw settings for individual commands:
101
+ The client's action methods accept a `redraw` object as an option. It applies to that call only:
107
102
 
108
103
  ```javascript
109
- // Enable redraw for a specific click
110
- await testdriver.find('load more').click({
111
- redraw: { enabled: true },
112
- });
104
+ // Wait for this key press even though redraw is off for the client
105
+ await testdriver.pressKeys(['enter'], { redraw: { enabled: true } });
113
106
 
114
- // Disable redraw for a fast interaction
115
- await testdriver.find('checkbox').click({
116
- redraw: false,
117
- });
107
+ // Skip the wait for a click you know changes nothing on screen
108
+ await testdriver.click({ x: 640, y: 360, redraw: { enabled: false } });
118
109
  ```
119
110
 
120
- ## Network Settling
121
-
122
- When `networkMonitor` is enabled, the system also monitors sandbox network traffic:
111
+ This works on `testdriver.click()`, `hover()`, `type()`, `pressKeys()`, `scroll()`, and `focusApplication()`.
123
112
 
124
- - Polls for `totalBytesReceived` and `totalBytesSent` from the sandbox
125
- - Keeps the last **60 measurements**
126
- - Calculates z-scores for both RX and TX byte rates
127
- - Network is **settled** when both RX and TX z-scores are negative (traffic is below average)
128
- - Has a **10-second timeout** for network polling
129
- - Non-critical: network errors are logged but never throw
113
+ - Pass an object. A per-command `redraw: true` or `redraw: false` is ignored.
114
+ - Element methods such as `element.click()` don't take options. They always use the client's setting.
130
115
 
131
- The final settling condition requires **both** screen AND network to be settled (when both are enabled).
116
+ ## Watch it work
132
117
 
133
- ## Events
118
+ Redraw emits two events on the client's [event emitter](/events#redraw-events):
134
119
 
135
- The redraw system emits events through the SDK emitter. See [Events](/events) for the full event reference.
136
-
137
- | Event | Description |
138
- |---|---|
139
- | `redraw:status` | Emitted on each poll with current screen diff, network stats, and timeout info |
140
- | `redraw:complete` | Emitted when redraw resolves (settled or timed out) |
120
+ - `redraw:status` on every check, with the current screen and network state.
121
+ - `redraw:complete` when the wait ends, with `isTimeout` and `timeElapsed`.
141
122
 
142
123
  ```javascript
143
- testdriver.emitter.on('redraw:status', (status) => {
144
- console.log(`Screen: ${status.redraw.text}`);
145
- console.log(`Network: ${status.network.text}`);
146
- console.log(`Timeout: ${status.timeout.text}`);
147
- });
148
-
149
- testdriver.emitter.on('redraw:complete', (result) => {
150
- if (result.isTimeout) {
151
- console.warn(`Redraw timed out after ${result.timeElapsed}ms`);
152
- } else {
153
- console.log(`Screen settled in ${result.timeElapsed}ms`);
124
+ testdriver.getEmitter().on('redraw:complete', ({ isTimeout, timeElapsed }) => {
125
+ if (isTimeout) {
126
+ console.warn(`Screen didn't settle within ${timeElapsed} ms`);
154
127
  }
155
128
  });
156
129
  ```
157
130
 
158
- ## When to Use Redraw
159
-
160
- **Enable redraw when:**
161
- - Testing single-page applications (SPAs) with route transitions
162
- - Interacting with pages that lazy-load content on scroll
163
- - Clicking buttons that trigger animations or modals
164
- - Testing apps with significant network-driven UI updates
165
-
166
- **Keep redraw disabled when:**
167
- - Tests are already stable without it
168
- - You want faster test execution
169
- - Your application has minimal animations
170
- - You're using explicit waits or assertions instead
171
-
172
- ## Types
173
-
174
- ```typescript
175
- interface RedrawConfig {
176
- enabled?: boolean; // Default: false (since v7.3)
177
- screenRedraw?: boolean; // Default: true
178
- networkMonitor?: boolean; // Default: false
179
- }
180
-
181
- interface RedrawStatusEvent {
182
- redraw: {
183
- enabled: boolean;
184
- settled: boolean;
185
- hasChangedFromInitial: boolean;
186
- consecutiveFramesStable: number;
187
- diffFromInitial: number;
188
- diffFromLast: number;
189
- text: string;
190
- };
191
- network: {
192
- enabled: boolean;
193
- settled: boolean;
194
- rxBytes: number;
195
- txBytes: number;
196
- text: string;
197
- };
198
- timeout: {
199
- isTimeout: boolean;
200
- elapsed: number;
201
- max: number;
202
- text: string;
203
- };
204
- }
205
-
206
- interface RedrawCompleteEvent {
207
- screenSettled: boolean;
208
- hasChangedFromInitial: boolean;
209
- consecutiveFramesStable: number;
210
- networkSettled: boolean;
211
- isTimeout: boolean;
212
- timeElapsed: number;
213
- }
214
- ```
131
+ ## When to use it
132
+
133
+ Turn redraw on when:
134
+
135
+ - Clicks open pages, modals, or menus that animate in.
136
+ - Scrolling loads more content.
137
+ - Typing triggers autocomplete or validation messages.
138
+
139
+ Leave it off when:
140
+
141
+ - Your tests already pass reliably without it. Each action takes longer with it on.
142
+ - Many actions don't visibly change the screen.
143
+ - You already wait with `find()` and a `timeout`, which keeps looking until the element appears.
144
+
145
+ ## Related
146
+
147
+ - [Options](/options#redraw-detection): every client option
148
+ - [Events](/events): the full list of events
149
+ - [wait()](/wait): pause for a fixed time
150
+ - [Locate elements](/locating-elements): wait for an element to appear with `find()`