Crate chromiumoxide[][src]

A high-level API for programmatically interacting with the Chrome DevTools Protocol.

This crate uses the [Chrome DevTools protocol] to drive/launch a Chromium or Chrome (potentially headless) browser.

Example

use futures::StreamExt;
use chromiumoxide::{Browser, BrowserConfig};

#[async_std::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {

    let (browser, mut handler) =
        Browser::launch(BrowserConfig::builder().with_head().build()?).await?;

    let handle = async_std::task::spawn(async move {
        loop {
            let _event = handler.next().await.unwrap();
        }
    });

    let page = browser.new_page("https://en.wikipedia.org").await?;

    // type into the search field and hit `Enter`,
    // this triggers a navigation to the search result page
    page.find_element("input#searchInput")
            .await?
            .click()
            .await?
            .type_str("Rust programming language")
            .await?
            .press_key("Enter")
            .await?;

    let html = page.wait_for_navigation().await?.content().await?;

    handle.await;
    Ok(())
}

The [chromiumoxide_pdl] crate contains a PDL parser, which is a rust rewrite of a python script in the chromium source tree and a Generator that turns the parsed PDL files into rust code. The chromiumoxide_cdp crate only purpose is to integrate the generator during is build process and include the generated output before compiling the crate itself. This separation is done merely because the generated output is ~60K lines of rust code (not including all the Proc macro extensions). So expect the compilation to take some time.

The generator can be configured and used independently, see [build.rs] of chromiumoxide_cdp.

chromedp rust-headless-chrome which the launch config, KeyDefinition and typing support is taken from. puppeteer

Re-exports

pub use chromiumoxide_types as types;
pub use crate::browser::Browser;
pub use crate::browser::BrowserConfig;
pub use crate::conn::Connection;
pub use crate::element::Element;
pub use crate::error::Result;
pub use crate::handler::Handler;
pub use crate::page::Page;

Modules

auth
browser
cdp

reexport the generated cdp types

conn
element
error
fetcher
handler
js
keys

Code based on rust-headless-chrome

layout

Code based on rust-headless-chrome

listeners
page

Structs

Binary

Represents a binary type as defined in the CDP protocol.

Traits

Command

Trait that all the request types have to implement.

Method

Methods are message types that contain the field method = Self::identifier() in their json body.

MethodType

A trait that identifies a method on type level