8 releases

Uses new Rust 2021

0.4.0 Oct 29, 2022
0.3.5 Mar 28, 2022
0.3.4 Dec 16, 2021
0.3.1 Jul 19, 2021
0.1.0 Dec 13, 2020

#8 in WebSocket

Download history 666/week @ 2022-08-20 726/week @ 2022-08-27 638/week @ 2022-09-03 722/week @ 2022-09-10 769/week @ 2022-09-17 828/week @ 2022-09-24 921/week @ 2022-10-01 793/week @ 2022-10-08 2022/week @ 2022-10-15 2725/week @ 2022-10-22 2771/week @ 2022-10-29 1581/week @ 2022-11-05 836/week @ 2022-11-12 694/week @ 2022-11-19 770/week @ 2022-11-26 1042/week @ 2022-12-03

3,521 downloads per month
Used in 4 crates (via chromiumoxide)


74K SLoC


Build Crates.io Documentation

chromiumoxide provides a high-level and async API to control Chrome or Chromium over the DevTools Protocol. It comes with support for all types of the Chrome DevTools Protocol and can launch a headless or full (non-headless) Chrome or Chromium instance or connect to an already running instance.


use futures::StreamExt;

use chromiumoxide::browser::{Browser, BrowserConfig};

async fn main() -> Result<(), Box<dyn std::error::Error>> {
   // create a `Browser` that spawns a `chromium` process running with UI (`with_head()`, headless is default) 
   // and the handler that drives the websocket etc.
    let (browser, mut handler) =
   // spawn a new task that continuously polls the handler
    let handle = async_std::task::spawn(async move {
        loop {
           let _ = handler.next().await.unwrap();
   // create a new browser page and navigate to the url
    let page = browser.new_page("https://en.wikipedia.org").await?;
   // find the search bar type into the search field and hit `Enter`,
   // this triggers a new navigation to the search result page
           .type_str("Rust programming language")

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

The current API still lacks some functionality, but the Page::execute function allows sending all chromiumoxide_types::Command types (see Generated Code). Most Element and Page functions are basically just simplified command constructions and combinations, like Page::pdf:

pub async fn pdf(&self, params: PrintToPdfParams) -> Result<Vec<u8>> {
     let res = self.execute(params).await?;

If you need something else, the Page::execute function allows for writing your own command wrappers. PRs are very welcome if you think a meaningful command is missing a designated function.

Add chromiumoxide to your project

chromiumoxide comes with support for the async-std and tokio runtime.

By default chromiumoxide is configured with async-std.

Use chromiumoxide with the async-std runtime:

chromiumoxide = { git = "https://github.com/mattsse/chromiumoxide", branch = "main"}

To use the tokio runtime instead add features = ["tokio-runtime"] and set default-features = false to disable the default runtime (async-std):

chromiumoxide = { git = "https://github.com/mattsse/chromiumoxide", features = ["tokio-runtime"], default-features = false, branch = "main"}

This configuration is made possible primarily by the websocket crate of choice: async-tungstenite.

Generated Code

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 invoke the generator during its 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 expansions). So expect the compiling to take some time. The generator can be configured and used independently, see chromiumoxide_cdp/build.rs.

Every chrome pdl domain is put in its own rust module, the types for the page domain of the browser_protocol are in chromiumoxide_cdp::cdp::browser_protocol::page, the runtime domain of the js_protocol in chromiumoxide_cdp::cdp::js_protocol::runtime and so on.

vanilla.aslushnikov.com is a great resource to browse all the types defined in the pdl files. This site displays Command types as defined in the pdl files as Method. chromiumoxid sticks to the Command nomenclature. So for everything that is defined as a command type in the pdl (=marked as Method on vanilla.aslushnikov.com) chromiumoxide contains a type for command and a designated type for the return type. For every command there is a <name of command>Params type with builder support (<name of command>Params::builder()) and its corresponding return type: <name of command>Returns. All commands share an implementation of the chromiumoxide_types::Command trait. All Events are bundled in single enum (CdpEvent)

Known Issues

  • The rust files generated for the PDL files in chromiumoxide_cdp don't compile when support for experimental types is manually turned off (export CDP_NO_EXPERIMENTAL=true). This is because the use of some experimental pdl types in the *.pdl files themselves are not marked as experimental.
  • chromiumoxide requires an installed chromium application and may not be able to find it on its own. The option to download chromium certainly would be a handy feature.


Q: A new chromium instance is being launched but then times out.

A: Check that your chromium language settings are set to English. chromiumoxide tries to parse the debugging port from the chromium process output and that is limited to english.


Licensed under either of these:



~69K SLoC