Skip to main content

Crate cdp_browser_lite

Crate cdp_browser_lite 

Source
Expand description

§cdp-browser-lite

Total lifecycle control for Chrome instances, seamlessly integrating with cdp-lite.

Provides the ability to spawn, attach, and manage Google Chrome or Chromium instances, ensuring correct cleanup, avoiding zombie processes, and offering a reliable interface for Headless Chrome automation.

§Example

use std::time::Duration;
use cdp_browser_lite::browser::Browser;
use cdp_browser_lite::config::{BrowserConfig, LaunchMode};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = BrowserConfig::builder()
        .mode(LaunchMode::LaunchNew)
        .port(0) // Ephemeral port
        .headless(true)
        .build();

    // Launch the browser
    let browser = Browser::ensure(config).await?;
    let (host, port) = browser.debug_address();
    println!("Chrome launched at {host}:{port}");

    // Obtain a CDP client directly from the browser
    let mut client = browser.client().await?;
     
    // Stop the browser cleanly
    browser.stop().await?;
    Ok(())
}

Re-exports§

pub use browser::Browser;
pub use config::BrowserConfig;
pub use config::LaunchMode;
pub use config::ProfileMode;
pub use error::BrowserError;

Modules§

browser
config
discovery
error
ports
probe
process
profile

Structs§

CdpClient
EventFilter
NoParams
WsCommand
WsResponse

Enums§

CdpError

Type Aliases§

CdpResult