Overview
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.Redraw is disabled by default since v7.3. Enable it explicitly if your tests interact with applications that have significant animations or loading states.
How It Works
Redraw uses a two-phase detection approach:- 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.
- 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.
Polling
The system polls at 500ms intervals, comparing screenshot frames. This reduces WebSocket traffic while still providing responsive detection.Pixel Comparison
Uses pixelmatch for per-pixel comparison with a threshold of0.1 for pixel sensitivity. A frame diff above 0.1% of total pixels indicates the screen has changed.
Z-Score Analysis
Screen stability uses statistical analysis of the last 10 measurements:- Calculate the mean and standard deviation of consecutive frame diffs
- Compute the z-score:
(currentDiff - mean) / stddev - Screen is stable when
diffPercent < 0.1%orz-score < 0(current diff is below the average)
Per-Command Timeouts
Each command type has a specific redraw timeout:| Command | Timeout | Reason |
|---|---|---|
click | 5000ms | Page navigations, modal openings |
hover (within click) | 5000ms | Same as click |
hover (standalone) | 2500ms | Tooltip animations |
scroll | 5000ms | Lazy-loaded content |
type | 5000ms | Autocomplete, validation |
pressKeys | 5000ms | Keyboard shortcuts may trigger changes |
focusApplication | 1000ms | Window focus animations |
redraw:complete event.
Configuration
Constructor Options
Redraw configuration. Pass
true/false for shorthand, or an object for fine-grained control.Per-Command Override
Override redraw settings for individual commands:Network Settling
WhennetworkMonitor is enabled, the system also monitors sandbox network traffic:
- Polls for
totalBytesReceivedandtotalBytesSentfrom the sandbox - Keeps the last 60 measurements
- Calculates z-scores for both RX and TX byte rates
- Network is settled when both RX and TX z-scores are negative (traffic is below average)
- Has a 10-second timeout for network polling
- Non-critical: network errors are logged but never throw
Events
The redraw system emits events through the SDK emitter. See Events for the full event reference.| Event | Description |
|---|---|
redraw:status | Emitted on each poll with current screen diff, network stats, and timeout info |
redraw:complete | Emitted when redraw resolves (settled or timed out) |
When to Use Redraw
Enable redraw when:- Testing single-page applications (SPAs) with route transitions
- Interacting with pages that lazy-load content on scroll
- Clicking buttons that trigger animations or modals
- Testing apps with significant network-driven UI updates
- Tests are already stable without it
- You want faster test execution
- Your application has minimal animations
- You’re using explicit waits or assertions instead

