Skip to main content
export declare function clickUntilExhausted(input: {
  page: Page;
  buttonLocator: Locator;
  heartbeat?: CallableFunction;
  containerLocator?: Locator;
  maxClicks?: number;
  clickDelay?: number;
  noChangeThreshold?: number;
}): Promise<void>;
Repeatedly click a button until no new content appears or max clicks reached. This function is useful for “Load More” buttons or paginated content where you need to keep clicking until all content is loaded. It provides several stopping conditions:
  • Button becomes invisible
  • Button becomes disabled
  • Maximum number of clicks reached
  • No change detected in container content (when containerLocator is provided)

Examples

import { clickUntilExhausted } from "@intuned/browser";
export default async function handler(params, page, context){
await page.goto("https://example.com/products");
const loadMoreButton = page.locator("button:has-text('Load More')");

// Click until button disappears or is disabled
await clickUntilExhausted({
  page,
  buttonLocator: loadMoreButton,
  maxClicks: 20
});
}

Arguments

input
Object
required
Configuration options

Returns: Promise<void>

Promise that resolves when clicking is exhausted