DocsWait Utilitiesbrowser_wait_for_function

browser_wait_for_function

Browser Wait For Function

Wait for a custom JavaScript condition to become true. Useful for waiting on application-specific state like 'window.appReady' or complex DOM conditions that can't be expressed with a selector.

Usage Example

123456789101112
import asyncio
from owl_browser import OwlBrowser, RemoteConfig
# Async usage
async with OwlBrowser(config) as browser:
context = await browser.create_context()
context_id = context["context_id"]
await browser.wait_for_function(
context_id=context_id,
js_function="value"
)

Parameters

Required

context_idstringrequired

The unique identifier of the browser context (e.g., 'ctx_000001')

js_functionstringrequired

JavaScript code that returns truthy value when condition is met. Executed repeatedly until true or timeout. Examples: 'return document.querySelector(".loaded") !== null', 'return window.dataReady === true'

Optional

pollingstring

Interval between function evaluations in milliseconds. Lower = more responsive but more CPU. Default: 100ms

timeoutstring

Maximum time to wait for function to return true. Default: 30000 (30 seconds)

Response

Returns a JSON object with the operation result.

{
  "success": true,
  "result": <value>
}