Skip to main content
This function uses AI and incurs costs.
Uses AI vision to determine if a webpage has finished loading by analyzing a screenshot. Detects loading spinners, blank content, or incomplete page states.
async def is_page_loaded(
    page: Page,
    *,
    model: str,
    timeout_s: int,
    api_key: str | None,
) -> bool

Examples

from typing import TypedDict
from playwright.async_api import Page
from intuned_browser.ai import is_page_loaded
class Params(TypedDict):
    pass
async def automation(page: Page, params: Params, **_kwargs):
    # Wait for page to finish loading
    await page.goto('https://sandbox.intuned.dev/')
    page_loaded = await is_page_loaded(page)
    if page_loaded:
        # Continue with scraping or interactions
        print("Page is loaded")
    else:
        # Wait longer or retry
        await page.wait_for_timeout(5000)

Arguments

page
Page
required
The Playwright page to check
timeout_s
int
Screenshot timeout in seconds. Defaults to 10.
model
str
AI model to use for the check. Defaults to “claude-haiku-4-5-20251001”.
api_key
str
Optional API key for the AI service (if provided, will not be billed to your account). Defaults to None.

Returns: bool

True if page is loaded, False if still loading