browser_commander/
lib.rs

1//! Browser Commander - Universal Browser Automation Library
2//!
3//! A Rust library for browser automation that provides a unified API
4//! for different browser automation engines.
5//!
6//! # Features
7//!
8//! - Unified API across multiple browser engines
9//! - Built-in navigation safety handling
10//! - Element visibility and scroll management
11//! - Click, fill, and other interaction support with verification
12//! - Async/await support with Tokio
13//!
14//! # Example
15//!
16//! ```rust,no_run
17//! use browser_commander::browser::{LaunchOptions, launch_browser};
18//!
19//! #[tokio::main]
20//! async fn main() -> anyhow::Result<()> {
21//!     // Launch a browser
22//!     let options = LaunchOptions::chromiumoxide()
23//!         .headless(true);
24//!
25//!     let result = launch_browser(options).await?;
26//!     println!("Browser launched: {:?}", result.browser.engine);
27//!
28//!     Ok(())
29//! }
30//! ```
31//!
32//! # Modules
33//!
34//! - [`core`] - Core types and traits (constants, engine adapter, logger)
35//! - [`elements`] - Element operations (selectors, visibility, content)
36//! - [`interactions`] - User interactions (click, scroll, fill)
37//! - [`browser`] - Browser management (launcher, navigation)
38//! - [`utilities`] - General utilities (URL handling, wait operations)
39//! - [`high_level`] - High-level DRY utilities
40
41pub mod browser;
42pub mod core;
43pub mod elements;
44pub mod high_level;
45pub mod interactions;
46pub mod utilities;
47
48// Re-export commonly used items at crate root
49pub use browser::{launch_browser, Browser, LaunchOptions, LaunchResult};
50pub use core::{
51    EngineAdapter, EngineError, EngineType, Logger, LoggerOptions, Timing, CHROME_ARGS, TIMING,
52};
53
54/// Prelude module for convenient imports.
55///
56/// Import everything commonly needed with:
57/// ```rust
58/// use browser_commander::prelude::*;
59/// ```
60pub mod prelude {
61    pub use crate::browser::{
62        goto, launch_browser, verify_navigation, wait_for_navigation, wait_for_url_stabilization,
63        Browser, LaunchOptions, LaunchResult, NavigationOptions, NavigationResult, WaitUntil,
64    };
65    pub use crate::core::{
66        is_navigation_error, is_timeout_error, EngineAdapter, EngineError, EngineType, Logger,
67        LoggerOptions, Timing, CHROME_ARGS, TIMING,
68    };
69    pub use crate::elements::{
70        count, get_attribute, input_value, is_enabled, is_visible, normalize_selector,
71        text_content, ParsedSelector,
72    };
73    pub use crate::high_level::{
74        check_and_clear_flag, find_toggle_button, install_click_listener, wait_for_url_condition,
75    };
76    pub use crate::interactions::{
77        click_button, click_element, fill_text_area, perform_fill, scroll_into_view,
78        scroll_into_view_if_needed, ClickOptions, ClickResult, FillOptions, FillResult,
79        ScrollBehavior, ScrollOptions, ScrollResult,
80    };
81    pub use crate::utilities::{
82        evaluate, get_domain, get_url, parse_url, safe_evaluate, same_origin, unfocus_address_bar,
83        wait, wait_with_cancel, WaitResult,
84    };
85}