Skip to main content
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)

Examples

Arguments

page
Page
required
Playwright Page object
button_locator
Locator
required
Locator for the button to click repeatedly
heartbeat
Callable[[], None]
Optional callback invoked after each click. Defaults to lambda: None.
container_locator
Locator
Optional content container to detect changes. Defaults to None.
max_clicks
int
Maximum number of times to click the button. Defaults to 50.
click_delay
float
Delay after each click (in seconds). Defaults to 0.5.
no_change_threshold
int
Minimum change in content size to continue clicking. Defaults to 0.

Returns: None

Function completes when clicking is exhausted