Skip to main content
This function has multiple overloads
Waits for DOM mutations to settle. This helper uses a MutationObserver to monitor DOM changes and waits until the DOM has been stable (no mutations) for the specified settle_duration.

wait_for_dom_settled vs wait_for_network_settled

  • Use wait_for_dom_settled when watching DOM mutations (elements added/removed/modified, loading spinners, dynamic content injection)
  • Use wait_for_network_settled when watching network requests (API calls, form submissions, resource loading)
This pattern waits for existing DOM changes to complete without triggering any new actions. Useful after navigation or for waiting for animations.

Examples

Arguments

source
Page | Locator
required
Playwright Page or Locator object to monitor for DOM changes. Can be passed as positional or keyword argument. Use Page to monitor entire document, or Locator to watch specific element.
settle_duration
float
Duration in seconds that the DOM must remain stable (no mutations) to be considered “settled”. Defaults to 0.5.
timeout_s
float
Maximum seconds to wait for DOM to settle before raising an error. Defaults to 30.0.

Returns: bool

True if DOM settled successfully within timeout.

Raises

TimeoutError

If DOM doesn’t settle within timeout_s.