chromedriver-update

Crates.iochromedriver-update
lib.rschromedriver-update
version1.0.2
sourcesrc
created_at2024-08-08 03:29:04.227199
updated_at2024-08-15 09:16:55.671232
descriptionEnsure your Chromedriver remains up-to-date alongside your Chrome browser
homepagehttps://github.com/lichtcui/chromedriver-update
repositoryhttps://github.com/lichtcui/chromedriver-update
max_upload_size
id1329041
size75,303
Licht Cui (lichtcui)

documentation

README

chromedriver

Automatically download Chromedriver when browser/driver versions do not match.

usage

install

cargo install chromedriver-update

run

--browser-path: chrome browser path
--driver-path: chrome driver path, create when file not exist
# mac
chromedriver-update \
    --browser-path="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
    --driver-path="/usr/local/bin/chromedriver"

# linux
chromedriver-update \
    --browser-path="/usr/bin/google-chrome" \
    --driver-path="/usr/bin/chromedriver"

# windows (only tested in github workflow)
chromedriver-update \
    --browser-path="C:\setup-chrome\chromium\120.0.6099.109\x64\chrome.exe" \
    --driver-path="C:\setup-chrome\chromedriver.exe"

code usage

require rust >= v1.80

add package

cargo add chromedriver-update

code examples

  • /examples/default_args.rs
use chromedriver_update::ChromeDriver;

#[tokio::main]
async fn main() {
    let mut driver = ChromeDriver::new();
    driver.init().await.unwrap();

    println!("driver version {}", driver.version);
    println!("browser version {}", driver.browser_version);

    if driver.need_download() {
        driver.try_download().await.unwrap();
    }
}
  • /examples/custom_args.rs
use chromedriver_update::ChromeDriver;

#[tokio::main]
async fn main() {
    let mut driver = ChromeDriver::new();
    driver
        .set_driver_path("/usr/local/bin/chromedriver")
        .set_browser_path("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome")
        .set_connect_timeout(2000)
        .set_timeout(5000)
        .init()
        .await
        .unwrap();

    println!("driver version {}", driver.version);
    println!("browser version {}", driver.browser_version);

    if !driver.need_download() {
        println!("no need to update driver");
        return;
    }

    println!("updating driver ...");

    match driver.try_download().await {
        Ok(_) => println!("Download driver successful"),
        Err(err) => eprintln!("Download driver failed, {}", err),
    }
}
Commit count: 0

cargo fmt