- Decorator
- Direct Function Call (Callable Pattern)
- Wrapper Function Pattern
- Clicking buttons that dynamically add content
- Infinite scroll implementations
- Waiting for loading spinners to disappear
- Dynamic tables/lists being populated
- Client-side routing animations
Examples
Arguments
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: Callable
The decorated function that waits for DOM to settle after execution.
- The decorated function MUST have a
pageorsourceparameter (or receive a Locator)- Can monitor entire page (Page) or specific elements (Locator)
- DOM is “settled” when no mutations occur for settle_duration seconds
- Raises error on timeout (unlike wait_for_network_settled which logs warning)
- Use Locator to ignore unrelated DOM changes on other parts of the page