Skip to main content
  • Decorator
  • Wrapper Function Pattern
def wait_for_network_settled(
    func: Callable[[Page], Any] | None,
    *,
    timeout_s: int = 30,
    max_inflight_requests: int = 0,
)
Decorator that waits for network activity to settle after executing the decorated function.This helper monitors network requests and waits until all network activity has completed (or until max_inflight_requests is reached). It’s essential for handling dynamic content that loads via AJAX/fetch requests triggered by user interactions.Use this decorator for actions that trigger network requests:
  • Clicking buttons or links that load data
  • Submitting forms
  • Triggering filters or searches
  • Any interaction that initiates API calls

Examples

from intuned_browser import wait_for_network_settled
async def automation(page, params, **_kwargs):
    await page.goto("https://example.com")
    # Decorator without arguments (uses timeout_s=30, max_inflight_requests=0)
    @wait_for_network_settled
    async def click_load_more(page):
        await page.locator("button[data-action='load-more']").click()
    # Automatically waits for network to settle after clicking
    await click_load_more(page)
    # Network has settled, data is loaded

Arguments

func
Callable[[Page], Any]
required
The async function to decorate. Must accept a Page object as a parameter. If not provided, returns a parameterized decorator.
timeout_s
int
default:"30"
Maximum seconds to wait for network to settle. If timeout is reached, logs a warning and continues (doesn’t raise an error). Defaults to 30.
max_inflight_requests
int
Maximum number of ongoing requests to consider network as “settled”. Useful for pages with long-polling or streaming. Defaults to 0 (waits for all requests to complete).

Returns: Callable

The decorated function that waits for network to settle after execution.