ApplesauceOS
Read Markdown ↗Download .md

UIHelper.waitForAny

Wait for any of several possible screen states.

js
ui.waitForAny(selectors, optionsOrTimeout?)

Arguments

ArgumentTypeMeaning
selectorsarray1..32 selector objects or strings.
optionsOrTimeoutobject | numberOptional milliseconds, or {timeout:5000, interval:100, throwOnTimeout:true}. Interval is at least 10 ms.

Returns

First matching element in tree order, not selector priority. Timeout throws, or returns null when disabled.

Example

js
const ui = UIHelper.forApp("com.example.app");
const next = ui.waitForAny([{id: "results", visible: true}, {id: "networkError", visible: true}], 8000);
console.log(next.snapshot.identifier);

Notes

Replace example identifiers with selectors verified in your app. Pinning an app does not open it. Global shortcuts use the unpinned foreground-app client.

Also available as

waitForAny.

All JavaScript APIs · Automation playbook