| Crates.io | chrome-for-testing |
| lib.rs | chrome-for-testing |
| version | 0.2.0 |
| created_at | 2025-01-17 15:06:09.893499+00 |
| updated_at | 2025-09-28 13:37:08.400221+00 |
| description | Interact with the chrome-for-testing JSON API. |
| homepage | |
| repository | https://github.com/lpotthast/chrome-for-testing |
| max_upload_size | |
| id | 1520668 |
| size | 138,600 |
Provides serde-enabled type definitions covering the chrome-for-testing JSON API responses,
and programmatic access to the API endpoints through reqwest, allowing you to fetch information
about available Chrome and ChromeDriver versions for automated testing.
You may want to check out chrome-for-testing-manager, a
crate building upon this one to allow easy selection and installation of chrome-for-testing versions.
It also comes with support for the thirtyfour WebDriver crate.
Add this to your Cargo.toml:
[dependencies]
chrome-for-testing = "0.2.0"
Or use cargo add:
cargo add chrome-for-testing
reqwest for non-blocking HTTP requests.KnownGoodVersions - Get all historical Chrome versions.LastKnownGoodVersions - Get latest versions for each release channel.Use this API if you just want to know the latest version of one particular (or multiple) release channels.
use chrome_for_testing::api::channel::Channel;
use chrome_for_testing::api::last_known_good_versions::LastKnownGoodVersions;
use chrome_for_testing::error::Error;
#[tokio::main]
async fn main() -> Result<(), Error> {
let client = reqwest::Client::new();
let versions = LastKnownGoodVersions::fetch(client).await?;
// Get the stable channel version.
if let Some(stable) = versions.channels.get(&Channel::Stable) {
println!("Latest stable version: {}", stable.version);
// Print download URLs for all platforms.
for download in &stable.downloads.chrome {
println!("Available for platform '{}' at: {}", download.platform, download.url);
}
}
Ok(())
}
Use this API if you just want to know all historical version. Particularly useful if you plan to run a fixed version.
This example also shows how the Platform type can be used to filter available download URLs for the current platform.
use chrome_for_testing::api::known_good_versions::KnownGoodVersions;
use chrome_for_testing::api::platform::Platform;
use chrome_for_testing::error::Error;
#[tokio::main]
async fn main() -> Result<(), Error> {
let client = reqwest::Client::new();
let versions = KnownGoodVersions::fetch(client).await?;
println!("Found {} Chrome versions", versions.versions.len());
// Find a specific version.
let target_version = "131.0.6778.204";
if let Some(version) = versions
.versions
.iter()
.find(|v| v.version.to_string() == target_version)
{
println!(
"Found version {}: revision {}",
version.version, version.revision
);
let current_platform = Platform::detect().expect("Running on supported platform.");
println!(
"Chrome downloads available for {} platforms",
version.downloads.chrome.len()
);
if let Some(download) = version
.downloads
.chrome
.iter()
.filter(|it| it.platform == current_platform)
.next()
{
println!(
"Found Chrome download URL for current platform '{current_platform}': {}",
download.url
);
}
// ChromeDriver downloads may not be available for older versions.
if let Some(chromedriver_downloads) = &version.downloads.chromedriver {
println!(
"ChromeDriver available for {} platforms",
chromedriver_downloads.len()
);
if let Some(download) = chromedriver_downloads
.iter()
.filter(|it| it.platform == current_platform)
.next()
{
println!(
"Found ChromeDriver download for current platform '{current_platform}': {}",
download.url
);
}
} else {
println!("No ChromeDriver downloads available for this version");
}
}
Ok(())
}
This project is licensed under either of
at your option.