> ## Documentation Index
> Fetch the complete documentation index at: https://intunedhq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# wait_for_network_settled

<Info>This function has multiple overloads</Info>

<Tabs>
  <Tab title="Wrapper Function Pattern">
    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](../functions/wait_for_dom_settled) when watching **DOM mutations** (elements added/removed/modified, loading spinners, dynamic content injection)

    ```python theme={null}
    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

    <CodeGroup>
      ```python Wrapper with Inline Function theme={null}
      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
      ```

      ```python Click Link with Network Wait theme={null}
      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/')
          # Click Object Extractors link and wait for page to load
          async def click_action():
              await page.get_by_text('Object Extractors').click()
          await wait_for_network_settled(
              page=page,
              func=click_action,
              timeout_s=10,
              max_inflight_requests=0
          )
          # Object Extractors page loaded
          title = await page.locator('div h2').inner_text()
          return title
      ```
    </CodeGroup>

    ## Arguments

    <ResponseField name="page" type="Page" required>
      Playwright Page object to monitor network activity on.
    </ResponseField>

    <ResponseField name="func" type="Callable[[], Any]" required>
      The async function to execute before waiting for network to settle. This function should contain the action that triggers network requests.
    </ResponseField>

    <ResponseField name="timeout_s" type="int">
      Maximum seconds to wait for network to settle. If timeout is reached, logs a warning and continues. Defaults to 30.
    </ResponseField>

    <ResponseField name="max_inflight_requests" type="int">
      Maximum number of ongoing requests to consider network as "settled". Defaults to 0 (waits for all requests).
    </ResponseField>
  </Tab>

  <Tab title="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](../functions/wait_for_dom_settled) when watching **DOM mutations** (elements added/removed/modified, loading spinners, dynamic content injection)

    ```python theme={null}
    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

    <CodeGroup>
      ```python Simple Decorator theme={null}
      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
      ```
    </CodeGroup>

    ## Arguments

    <ResponseField name="func" type="Callable[[Page], Any]" required>
      The async function to decorate. Must accept a Page object as a parameter. If not provided, returns a parameterized decorator.
    </ResponseField>

    <ResponseField name="timeout_s" type="int">
      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.
    </ResponseField>

    <ResponseField name="max_inflight_requests" type="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).
    </ResponseField>
  </Tab>
</Tabs>

## Returns: `Any`

The return value of the executed function.
