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/disabled
Maximum number of clicks reached
No change detected in container content (when container_locator is provided)
from typing import TypedDictfrom playwright.async_api import Pagefrom intuned_browser import click_until_exhaustedclass Params(TypedDict): passasync def automation(page: Page, params: Params, **_kwargs): await page.goto("https://sandbox.intuned.dev/load-more") load_more_button = page.locator("main main button") # Select the main button in the main content area. # Click until button disappears or is disabled await click_until_exhausted( page=page, button_locator=load_more_button, max_clicks=20 ) # Will keep clicking the button until the button disappears or is disabled or the max_clicks is reached.