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
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.
Duration in seconds that the DOM must remain stable (no mutations) to be considered “settled”. Defaults to 0.5.
Maximum seconds to wait for DOM to settle before raising an error. Defaults to 30.0.
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 executes a function and waits for DOM mutations to settle before returning.Examples
Arguments
Playwright Page or Locator object to monitor for DOM changes. Use Page for entire document, Locator for specific element.
func
Callable[[], Any]
required
The async function to execute before waiting for DOM to settle. This function should contain the action that triggers DOM changes.
Duration in seconds that the DOM must remain stable (no mutations) to be considered “settled”. Defaults to 0.5.
Maximum seconds to wait for DOM to settle before raising an error. Defaults to 30.0.
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 decorates a function to automatically wait for DOM to settle after execution.Examples
Arguments
func
Callable[[Page], Any] | Callable[[Locator], Any]
required
The async function to decorate. Must accept a Page or Locator object as a parameter. If not provided, returns a parameterized decorator.
Duration in seconds that the DOM must remain stable (no mutations) to be considered “settled”. Increase for slow animations. Defaults to 0.5.
Maximum seconds to wait for DOM to settle before timing out. Raises an error if timeout is reached. Defaults to 30.0.
Returns: bool
True if DOM settled successfully within timeout.
Raises
TimeoutError
If DOM doesn’t settle within timeout_s.