SeleniumHQ/selenium · error · anyhow::Error

Unable to download {} in offline mode

Error message

Unable to download {} in offline mode

What it means

Produced by assert_online_or_err() using the OFFLINE_DOWNLOAD_ERR_MSG constant ("Unable to download {} in offline mode"). It fires from the download step (lib.rs:985) when Selenium Manager is offline but a driver binary must be fetched. The placeholder is the driver name.

Source

Thrown at rust/src/lib.rs:1171

        let mut release_version = driver_version.to_string();
        if !driver_version.ends_with('0') && !self.is_nightly(driver_version) {
            // E.g.: version 4.8.1 is shipped within release 4.8.0
            let error_message = format!(
                "Wrong {} version: '{}'",
                self.get_driver_name(),
                driver_version
            );
            let index = release_version.rfind('.').ok_or(anyhow!(error_message))? + 1;
            release_version = release_version[..index].to_string();
            release_version.push('0');
        }
        Ok(format!("selenium-{release_version}"))
    }

    fn assert_online_or_err(&self, message: &str) -> Result<(), Error> {
        if self.is_offline() {
            return Err(anyhow!(format_one_arg(message, self.get_driver_name())));
        }
        Ok(())
    }

    fn get_driver_name_with_extension(&self) -> String {
        format!(
            "{}{}",
            self.get_driver_name(),
            get_binary_extension(self.get_os())
        )
    }

    fn get_browser_name_with_extension(&self) -> String {
        format!(
            "{}{}",
            self.get_browser_name(),
            get_binary_extension(self.get_os())
        )

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Restore connectivity for the initial download, then run offline subsequently (the cached driver will be reused).
  2. Manually place the driver in the Selenium cache directory before running.
  3. Pin the driver version and pre-seed the cache from another machine.

Example fix

# before
selenium-manager --browser chrome --offline   # cache miss -> error
# after (seed cache once online, then run offline)
selenium-manager --browser chrome            # populates cache
selenium-manager --browser chrome --offline  # now uses cache
Defensive patterns

Strategy: validation

Validate before calling

// Verify the driver is already cached before running offline
use std::path::PathBuf;
fn driver_cached(driver_name: &str, cache: &PathBuf) -> bool {
    cache.read_dir().map(|entries| entries
        .filter_map(Result::ok)
        .any(|e| e.file_name().to_string_lossy().contains(driver_name)))
        .unwrap_or(false)
}
if offline && !driver_cached("chromedriver", &cache_path) {
    return Err(anyhow!("seed cache before going offline"));
}

Prevention

When it happens

Trigger: is_offline() is true and the flow reaches the driver-download step (assert_online_or_err(OFFLINE_DOWNLOAD_ERR_MSG) at lib.rs:985), i.e. the driver is not in cache and must be downloaded.

Common situations: Offline host with a cache miss; first run on an air-gapped machine; cache was cleared (selenium-manager --clear-cache) while offline.

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/0b9adb9089c7f53a. Report an issue: GitHub.