This function has multiple overloads
- Direct Function Call (Callable Pattern)
- Wrapper Function Pattern
- Decorator
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.
This pattern waits for existing DOM changes to complete without triggering any new actions. Useful after navigation or for waiting for animations.
wait_for_dom_settled vs wait_for_network_settled
- Use
wait_for_dom_settledwhen 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)
Examples
Arguments
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.
float
Duration in seconds that the DOM must remain stable (no mutations) to be considered “settled”. Defaults to 0.5.
float
Maximum seconds to wait for DOM to settle before raising an error. Defaults to 30.0.