WaitFor
This tool on every surface: CLI · MCP · Python · JavaScript · Go · Java · .NET
Wait until an element appears, disappears, shows particular text, or reaches a state — enabled, checked, focused, holding a value — then return. These call app_wait_for.
WaitFor
func (d *Device) WaitFor(ctx context.Context, target string, opts *WaitOptions) (*Element, error)
WaitFor blocks until the screen agrees, instead of sleeping.
On success the screen is remapped, so the returned element already has a ref that can be tapped without calling Map first. Waiting for something to go away returns a nil element and a nil error, since there is nothing left to point at. If the condition never holds the error says what was on screen instead, which is usually the answer.
Examples
Wait for text to appear
el, err := dev.WaitFor(ctx, "text=Welcome back", nil)
if err != nil {
return err
}
fmt.Println(el.Ref)
Wait for a spinner to go
// Nothing is left to point at, so the element is nil.
if _, err := dev.WaitFor(ctx, "role=progressbar", &mobium.WaitOptions{Condition: mobium.Hidden}); err != nil {
return err
}
Wait for a checkbox to be checked, for up to five seconds
opts := &mobium.WaitOptions{Condition: mobium.Checked, Timeout: 5 * time.Second}
if _, err := dev.WaitFor(ctx, "testid=termsCheck", opts); err != nil {
return err
}
The same call from the command line, mobium wait testid=termsCheck --for checked --timeout 5s, printed on an Android 15 emulator:
testid=termsCheck is checked after 18ms — @e3 Accept terms (checkbox, checked)
On a device

mobium wait testid=loginError --for text --text 'Incorrect username or password.' on an Android 15 emulator