chrome-for-testing 0.4.0

Interact with the chrome-for-testing JSON API.
Documentation

chrome-for-testing

Provides serde-enabled type definitions covering the main chrome-for-testing JSON API responses with download URLs, and programmatic access to those endpoints through reqwest, allowing you to fetch information about available Chrome, ChromeDriver, and Chrome Headless Shell versions for automated testing.

Links

Related Crates

chrome-for-testing-manager

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.

Installation

Add this to your Cargo.toml:

[dependencies]
chrome-for-testing = "0.4"

Or use cargo add:

cargo add chrome-for-testing

Features

  • Type-safe API access - Serde-enabled type definitions for the main API responses with download URLs.
  • Async support - Built on reqwest for non-blocking HTTP requests.
  • Provides access to the following APIs:
    • KnownGoodVersions - Get all historical Chrome versions.
    • LastKnownGoodVersions - Get latest versions for each release channel.
  • Platform detection - Automatically detect the current platform (os/arch) to filter responses.
  • Typed URL access - Parse download URL strings into url::Url values with Download::parsed_url().
  • ChromeDriver utilities - Additional tools for ChromeDriver configuration.

Usage

Getting the "Last Known Good Versions"

Use this API if you just want to know the latest version of one particular (or multiple) release channels.

use chrome_for_testing::{LastKnownGoodVersions, Result};

#[tokio::main]
async fn main() -> Result<()> {
    let client = reqwest::Client::new();
    let versions = LastKnownGoodVersions::fetch(&client).await?;

    // Get the stable channel version.
    if let Some(stable) = versions.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(())
}

Getting all "Known Good Versions"

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::{DownloadsByPlatform, KnownGoodVersions, Platform, Result, Version};

#[tokio::main]
async fn main() -> Result<()> {
    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: Version = "131.0.6778.204".parse().unwrap();
    if let Some(version) = versions
        .versions
        .iter()
        .find(|v| v.version == 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.for_platform(current_platform) {
            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.for_platform(current_platform) {
                println!(
                    "Found ChromeDriver download for current platform '{current_platform}': {}",
                    download.url
                );
            }
        } else {
            println!("No ChromeDriver downloads available for this version");
        }
    }

    Ok(())
}

Fetch and platform detection APIs return chrome_for_testing::Result<T>, a rootcause typed error report. If your application uses a generic error boundary, convert the report with err.into_boxed_error().

Modeled API's

This crate currently models

Modeled Endpoint Description
no known-good-versions.json The versions for which all CfT assets are available for download. Useful for bisecting.
yes known-good-versions-with-downloads.json Same as above, but with an extra downloads property for each version, listing the full download URLs per asset.
no last-known-good-versions.json The latest versions for which all CfT assets are available for download, for each Chrome release channel (Stable/Beta/Dev/Canary).
yes last-known-good-versions-with-downloads.json Same as above, but with an extra downloads property for each channel, listing the full download URLs per asset.
no latest-patch-versions-per-build.json The latest versions for which all CfT assets are available for download, for each known combination of MAJOR.MINOR.BUILD versions.
no latest-patch-versions-per-build-with-downloads.json Same as above, but with an extra downloads property for each version, listing the full download URLs per asset.
no latest-versions-per-milestone.json The latest versions for which all CfT assets are available for download, for each Chrome milestone.
no latest-versions-per-milestone-with-downloads.json Same as above, but with an extra downloads property for each milestone, listing the full download URLs per asset.

The (historical) LATEST_RELEASE_* endpoints are also not modeled.

License

This project is licensed under either of

at your option.