browser_wait_for_selector
Browser Wait For Selector
Wait for an element matching the selector to appear and become visible on the page. Essential for handling dynamic content that loads after navigation. Times out with error if element doesn't appear.
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_selector(
context_id=context_id,
selector="#element-id"
)
Parameters
Required
context_idstringrequiredThe unique identifier of the browser context (e.g., 'ctx_000001')
selectorstringrequiredCSS selector or natural language description of the element to wait for. Waits until the element exists in the DOM and is visible. Examples: '#login-form', '.results', 'the search results'
Optional
timeoutstringMaximum time to wait in milliseconds. Returns error if element doesn't appear within this time. Default: 5000 (5 seconds)
indexstringWhen multiple elements match the selector, wait for the Nth element (0-based). Default: -1 (first match)
Response
Returns a JSON object with the operation result.
{
"success": true,
"result": <value>
}