Crates.io | chromedriver-update |
lib.rs | chromedriver-update |
version | 1.0.2 |
source | src |
created_at | 2024-08-08 03:29:04.227199 |
updated_at | 2024-08-15 09:16:55.671232 |
description | Ensure your Chromedriver remains up-to-date alongside your Chrome browser |
homepage | https://github.com/lichtcui/chromedriver-update |
repository | https://github.com/lichtcui/chromedriver-update |
max_upload_size | |
id | 1329041 |
size | 75,303 |
Automatically download Chromedriver when browser/driver versions do not match.
cargo install chromedriver-update
# 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"
require rust >= v1.80
cargo add chromedriver-update
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();
}
}
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),
}
}