1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! # 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 loading
//! - [`DocumentLoadState::Load`] - Page is fully loaded including resources
//! - [`DocumentLoadState::NetworkIdle`] - No network activity for 500ms
//!
//! ## Usage in Navigation
//!
//! ```no_run
//! use viewpoint_core::{Browser, DocumentLoadState};
//!
//! # async fn example() -> Result<(), viewpoint_core::CoreError> {
//! # let browser = Browser::launch().headless(true).launch().await?;
//! # let context = browser.new_context().await?;
//! # let page = context.new_page().await?;
//! // 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?;
//! # Ok(())
//! # }
//! ```
//!
//! ## 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`](crate::page::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)
//!
//! ```no_run
//! use viewpoint_core::Browser;
//!
//! # async fn example() -> Result<(), viewpoint_core::CoreError> {
//! # let browser = Browser::launch().headless(true).launch().await?;
//! # let context = browser.new_context().await?;
//! # let page = context.new_page().await?;
//! // 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?;
//! # Ok(())
//! # }
//! ```
pub use DocumentLoadState;
pub use NavigationWaiter;
pub use ;