Skip to main content
The wait command polls for an element matching specified filters, blocking until the element appears or a timeout is reached.

Overview

This command is essential for handling dynamic UIs, page loads, and asynchronous operations where elements may not be immediately available.

Arguments

string
required
Application name or bundle identifier

Options

string
Filter by accessibility role
string
Filter by title (substring match)
string
Filter by label (substring match)
string
Filter by identifier (substring match)
number
default:"10.0"
Maximum time to wait in seconds
number
default:"0.5"
Polling interval in seconds (how often to check)
string
default:"text"
Output format: text or json

Examples

Wait for button to appear

Output:

Wait for alert dialog

Wait with custom interval

JSON output

Output:

Common use cases

Wait for page load

Wait for dialog to appear

Wait for async operation

Wait for element to be ready

Timeout behavior

When the timeout is reached without finding the element:
Output:
Exit code: non-zero

Error handling in scripts

Basic error handling

Retry logic

Fallback actions

Performance considerations

Polling interval

The --interval option controls how often the command checks for the element:
Use for:
  • Quick UI updates
  • Animations
  • Immediate feedback
Very small intervals (< 0.1s) may impact system performance without meaningful speed gains.

Timeout tuning

Choose appropriate timeouts based on expected operation duration:

Advanced patterns

Wait for element to disappear

Wait for multiple conditions

Wait with progress indication

Tips

Use specific filters to avoid matching unintended elements. Combine multiple filters for precision.
Set realistic timeouts based on your application’s behavior. Too short causes false failures; too long wastes time.
For very dynamic UIs, consider using --interval 0.1 or lower to catch short-lived elements.
The wait command returns immediately when the element is found - you don’t always wait the full timeout.
  • find - Search for elements without waiting
  • snapshot - Create element reference map
  • is enabled - Check if element is interactive
  • get text - Read element content after waiting