Skip to main content

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::{
50    emulate_media, launch_browser, Browser, ColorScheme, EmulateMediaOptions, LaunchOptions,
51    LaunchResult,
52};
53pub use core::{
54    DialogEvent, DialogManager, DialogType, EngineAdapter, EngineError, EngineType, Logger,
55    LoggerOptions, PdfOptions, Timing, CHROME_ARGS, TIMING,
56};
57
58/// Prelude module for convenient imports.
59///
60/// Import everything commonly needed with:
61/// ```rust
62/// use browser_commander::prelude::*;
63/// ```
64pub mod prelude {
65    pub use crate::browser::{
66        emulate_media, goto, launch_browser, verify_navigation, wait_for_navigation,
67        wait_for_url_stabilization, Browser, ColorScheme, EmulateMediaOptions, LaunchOptions,
68        LaunchResult, NavigationOptions, NavigationResult, WaitUntil,
69    };
70    pub use crate::core::{
71        is_navigation_error, is_timeout_error, DialogEvent, DialogManager, DialogType,
72        EngineAdapter, EngineError, EngineType, Logger, LoggerOptions, PdfOptions, Timing,
73        CHROME_ARGS, TIMING,
74    };
75    pub use crate::elements::{
76        count, get_attribute, input_value, is_enabled, is_visible, normalize_selector,
77        text_content, ParsedSelector,
78    };
79    pub use crate::high_level::{
80        check_and_clear_flag, find_toggle_button, install_click_listener, wait_for_url_condition,
81    };
82    pub use crate::interactions::{
83        click_button, click_element, fill_text_area, key_down, key_up, perform_fill, press_key,
84        scroll_into_view, scroll_into_view_if_needed, type_text, ClickOptions, ClickResult,
85        FillOptions, FillResult, ScrollBehavior, ScrollOptions, ScrollResult,
86    };
87    pub use crate::utilities::{
88        evaluate, get_domain, get_url, parse_url, safe_evaluate, same_origin, unfocus_address_bar,
89        wait, wait_with_cancel, WaitResult,
90    };
91}