Waits for a JavaScript function or predicate to return a truthy value when executed in the page’s context. Example: waitForFunction(functionOrPredicate: "() => window.myAppInitialized === true") Returns true if the function returns truthy within the timeout.

Definition

waitForFunction(
  functionOrPredicate: String!
  arg: JSON
  options: WaitForFunctionOptions
): Boolean!

Arguments

functionOrPredicate

String! A string containing the JavaScript function or predicate to evaluate. It should return a truthy value when the condition is met. Example: "() => document.querySelector('#dynamicElement') !== null"

arg

JSON An optional JSON serializable argument to pass to the function.

options

WaitForFunctionOptions Options for waiting, such as polling interval and timeout.

Returns

Boolean! The Boolean scalar type represents true or false.