This function has multiple overloads
Wrapper Function Pattern
Decorator
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)
async def wait_for_network_settled (
* ,
page : Page,
func : Callable[[], Awaitable[Any]],
timeout_s : int ,
max_inflight_requests : int ,
) -> Any
This pattern executes a function and waits for network activity to settle before returning the result of the function. Examples Wrapper with Inline Function
Click Link with Network Wait
from typing import TypedDict
from playwright.async_api import Page
from intuned_browser import wait_for_network_settled
class Params ( TypedDict ):
pass
async def automation ( page : Page, params : Params, ** _kwargs ):
await page.goto( 'https://sandbox.intuned.dev/infinite-scroll' )
# Execute action and wait for network to settle
async def scroll_action ():
# scroll to load more content
await page.evaluate( "() => { window.scrollTo(0, document.body.scrollHeight); }" )
return "scrolled"
result = await wait_for_network_settled(
page = page,
func = scroll_action,
timeout_s = 15 ,
max_inflight_requests = 0
)
print (result) # "scrolled"
return result
Arguments Playwright Page object to monitor network activity on.
func
Callable[[], Any]
required
The async function to execute before waiting for network to settle. This function should contain the action that triggers network requests.
Maximum seconds to wait for network to settle. If timeout is reached, logs a warning and continues. Defaults to 30.
Maximum number of ongoing requests to consider network as “settled”. Defaults to 0 (waits for all requests).
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)
def wait_for_network_settled (
func : Callable[ ... , Awaitable[Any]],
) -> Callable[ ... , Awaitable[Any]]
This pattern decorates a function to automatically add network waiting functionality to the wrapped function. Examples from typing import TypedDict
from playwright.async_api import Page
from intuned_browser import wait_for_network_settled
class Params ( TypedDict ):
pass
async def automation ( page : Page, params : Params, ** _kwargs ):
await page.goto( "https://sandbox.intuned.dev/load-more" )
# Decorator without arguments (uses timeout_s=30, max_inflight_requests=0)
@wait_for_network_settled
async def click_load_more ( page ):
await page.locator( "main main button" ).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.
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.
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: Any
The return value of the executed function.