ApplesauceOS
Read Markdown ↗Download .md

UIHelper.waitFor

Wait for a custom read-only condition.

js
ui.waitFor(condition, optionsOrTimeout?)

Arguments

ArgumentTypeMeaning
conditionfunctionSynchronous callback receiving this query client. Return a truthy value when ready; do not return a Promise or perform actions.
optionsOrTimeoutobject | numberOptional milliseconds, or {timeout:5000, interval:100, throwOnTimeout:true}. Interval is at least 10 ms.

Returns

First truthy callback result. Timeout throws, or returns null when disabled.

Example

js
const ui = UIHelper.forApp("com.example.app");
const row = ui.waitFor(q => q.findElements({type: "Cell", visible: true})
  .find(e => e.snapshot.label.startsWith("Order #")), 5000);
console.log(row.getText());

Notes

Callback errors propagate. Handle alert actions outside this read-only callback.

All JavaScript APIs · Automation playbook