Module wait

Module wait 

Source
Expand description

§Wait System

This module provides Playwright-compatible load states and auto-waiting functionality for reliable browser automation.

§Document Load States

The DocumentLoadState enum represents different stages of page loading:

§Usage in Navigation

use viewpoint_core::{Browser, DocumentLoadState};

// Wait for DOM to be ready (fastest)
page.goto("https://example.com")
    .wait_until(DocumentLoadState::DomContentLoaded)
    .goto()
    .await?;

// Wait for full load (default)
page.goto("https://example.com")
    .wait_until(DocumentLoadState::Load)
    .goto()
    .await?;

// Wait for network to be idle (slowest, most reliable for SPAs)
page.goto("https://example.com")
    .wait_until(DocumentLoadState::NetworkIdle)
    .goto()
    .await?;

§Choosing the Right Load State

StateWhen to Use
CommitWhen you only need the response headers
DomContentLoadedWhen DOM interaction is needed, but not full resources
LoadGeneral use, waits for images and stylesheets
NetworkIdleFor SPAs or pages with async data fetching

§Auto-Waiting in Locators

The Locator API automatically waits for elements to be actionable before performing actions. This includes waiting for:

  • Element to be attached to DOM
  • Element to be visible
  • Element to be stable (not animating)
  • Element to be enabled (for form elements)
  • Element to receive events (not obscured)
use viewpoint_core::Browser;

// This automatically waits for the button to be clickable
page.locator("button").click().await?;

// This waits for the input to be visible and enabled
page.locator("input").fill("text").await?;

Structs§

LoadStateWaiter
Waits for page load states by listening to CDP events.
NavigationResponseData
Captured response data during navigation.
NavigationWaiter
Waiter that detects and waits for navigation triggered by actions.

Enums§

DocumentLoadState
Document load states for navigation waiting.