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.
export declare function isPageLoaded(input: {
  page: Page;
  timeoutInMs?: number;
  model?: string;
  apiKey?: string;
}): Promise<boolean>;

Examples

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
required
Input object containing the page to check

Returns: Promise<boolean>

Promise resolving to true if page is loaded, false if still loading.