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.
export declare function isPageLoaded ( input : {
page : Page ;
timeoutInMs ?: number ;
model ?: string ;
apiKey ?: string ;
}) : Promise < boolean >;
Examples
Check Page Loading
Loading Loop
import { isPageLoaded } from "@intuned/browser/ai" ;
import { BrowserContext , Page } from "playwright" ;
interface Params {}
export default async function handler (
params : Params ,
page : Page ,
context : BrowserContext
) {
// Wait for page to finish loading
await page . goto ( "https://sandbox.intuned.dev/" );
const pageLoaded = await isPageLoaded ({ page });
if ( pageLoaded ) {
// Continue with scraping or interactions
console . log ( "Page is loaded" );
} else {
// Wait longer or retry
await page . waitForTimeout ( 5000 );
}
}
Arguments
Input object containing the page to check The Playwright page to check
Screenshot timeout in milliseconds. Defaults to 10000
AI model to use for the check. Defaults to “gpt-5-mini-2025-08-07”
Optional API key for the AI call.
Returns: Promise<boolean>
Promise resolving to true if page is loaded, false if still loading.