> ## Documentation Index
> Fetch the complete documentation index at: https://docs.extractbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# waitForFunction

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

```graphql theme={null}
waitForFunction(
  functionOrPredicate: String!
  arg: JSON
  options: WaitForFunctionOptions
): Boolean!
```

## Arguments

### `functionOrPredicate`

[String!](/reference/graphql/scalars/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](/reference/graphql/scalars/json)

An optional JSON serializable argument to pass to the function.

### `options`

[WaitForFunctionOptions](/reference/graphql/inputs/wait-for-function-options)

Options for waiting, such as polling interval and timeout.

## Returns

[Boolean!](/reference/graphql/scalars/boolean)

The `Boolean` scalar type represents `true` or `false`.
