Skip to main content
This function has multiple overloads
Executes a function and waits for network activity to settle before returning. This helper monitors network requests and waits until all network activity has completed.

wait_for_network_settled vs wait_for_dom_settled

  • Use wait_for_network_settled when watching network requests (API calls, form submissions, resource loading)
  • Use wait_for_dom_settled when watching DOM mutations (elements added/removed/modified, loading spinners, dynamic content injection)
This pattern executes a function and waits for network activity to settle before returning the result of the function.

Examples

Arguments

Page
required
Playwright Page object to monitor network activity on.
Callable[[], Any]
required
The async function to execute before waiting for network to settle. This function should contain the action that triggers network requests.
int
Maximum seconds to wait for network to settle. If timeout is reached, logs a warning and continues. Defaults to 30.
int
Maximum number of ongoing requests to consider network as “settled”. Defaults to 0 (waits for all requests).

Returns: Any

The return value of the executed function.