Skip to main content
async def scroll_to_load_content(
    source: Page | Locator,
    *,
    on_scroll_progress: Callable[[], None] | None = None,
    max_scrolls: int = 50,
    delay_s: float = 0.1,
    min_height_change: int = 100,
)
Automatically scrolls through infinite scroll content by repeatedly scrolling to the bottom until no new content loads or maximum scroll limit is reached.

Examples

from intuned_browser import scroll_to_load_content
async def automation(page, params, **_kwargs):
    await page.goto("https://docs.intunedhq.com/docs-old/getting-started/introduction")
    # Scroll through entire page content
    await scroll_to_load_content(source=page)
    # Now all content is loaded and visible

Arguments

source
Page | Locator
required
The Playwright page or locator object to scroll.
on_scroll_progress
Callable
Optional callback function to call during each scroll iteration. Defaults to lambda: None.
max_scrolls
int
default:"50"
Maximum number of scroll attempts before stopping. Defaults to 50.
delay_s
float
default:"0"
Delay in seconds between scroll attempts. Defaults to 0.1.
min_height_change
int
default:"100"
Minimum height change in pixels required to continue scrolling. Defaults to 100.

Returns: None

Function completes when scrolling is finished