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:
DocumentLoadState::Commit- Navigation has started (response headers received)DocumentLoadState::DomContentLoaded- DOM is ready, but resources may still be loadingDocumentLoadState::Load- Page is fully loaded including resourcesDocumentLoadState::NetworkIdle- No network activity for 500ms
§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
| State | When to Use |
|---|---|
Commit | When you only need the response headers |
DomContentLoaded | When DOM interaction is needed, but not full resources |
Load | General use, waits for images and stylesheets |
NetworkIdle | For 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§
- Load
State Waiter - Waits for page load states by listening to CDP events.
- Navigation
Response Data - Captured response data during navigation.
- Navigation
Waiter - Waiter that detects and waits for navigation triggered by actions.
Enums§
- Document
Load State - Document load states for navigation waiting.