Skip to main content
Waits for DOM mutations to settle without executing any function first. This helper uses a MutationObserver to monitor DOM changes and waits until the DOM has been stable (no mutations) for the specified settle duration.
export declare function waitForDomSettled(options: {
  source: Page | Locator;
  settleDurationMs?: number;
  timeoutInMs?: number;
}): Promise<boolean>;

waitForDomSettled vs withNetworkSettledWait

  • Use waitForDomSettled when watching DOM mutations (elements added/removed/modified, loading spinners, dynamic content injection)
  • Use withNetworkSettledWait when watching network requests (API calls, form submissions, resource loading)

Examples

import { waitForDomSettled } from "@intuned/browser";
import { BrowserContext, Page } from "playwright";

interface Params {}

export default async function handler(
  params: Params,
  page: Page,
  context: BrowserContext
) {
  // Navigate to page with dynamic content
  await page.goto("https://sandbox.intuned.dev/lists/table");

  // Wait for all DOM mutations to complete
  const settled = await waitForDomSettled({
    source: page,
    settleDurationMs: 1000,
    timeoutInMs: 20000,
  });

  if (settled) {
    // DOM is stable, safe to extract data
    const rows = await page.locator("table tr").all();
    return rows.length;
  }
  return 0;
}

Arguments

options
Object
required
Configuration object for DOM settlement monitoring

Returns: Promise<boolean>

Promise that resolves to true if DOM settled within timeout, false if timeout or error occurred