SeleniumHQ/selenium · error · anyhow::Error

Invalid driver name: {driver_name}

Error message

Invalid driver name: {driver_name}

What it means

Returned by get_manager_by_driver() when the driver name (case-insensitive) matches none of chromedriver, geckodriver, edgedriver, iedriver, or safaridriver. The original driver name is interpolated in the message.

Source

Thrown at rust/src/lib.rs:1750

        Ok(ElectronManager::new()?)
    } else {
        Err(anyhow!(format!("Invalid browser name: {browser_name}")))
    }
}

pub fn get_manager_by_driver(driver_name: String) -> Result<Box<dyn SeleniumManager>, Error> {
    if driver_name.eq_ignore_ascii_case(CHROMEDRIVER_NAME) {
        Ok(ChromeManager::new()?)
    } else if driver_name.eq_ignore_ascii_case(GECKODRIVER_NAME) {
        Ok(FirefoxManager::new()?)
    } else if driver_name.eq_ignore_ascii_case(EDGEDRIVER_NAME) {
        Ok(EdgeManager::new()?)
    } else if driver_name.eq_ignore_ascii_case(IEDRIVER_NAME) {
        Ok(IExplorerManager::new()?)
    } else if driver_name.eq_ignore_ascii_case(SAFARIDRIVER_NAME) {
        Ok(SafariManager::new()?)
    } else {
        Err(anyhow!(format!("Invalid driver name: {driver_name}")))
    }
}

pub fn clear_cache(log: &Logger, path: &str) {
    let cache_path = Path::new(path).to_path_buf();
    if cache_path.exists() {
        log.debug(format!("Clearing cache at: {}", cache_path.display()));
        fs::remove_dir_all(&cache_path).unwrap_or_else(|err| {
            log.warn(format!(
                "The cache {} cannot be cleared: {}",
                cache_path.display(),
                err
            ))
        });
    }
}

/// Removes cached driver and browser binaries whose `last_used` timestamp (tracked in the

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Use one of: chromedriver, geckodriver, edgedriver, iedriver, safaridriver.
  2. Drop file extensions and version suffixes from the driver name.
  3. Check spelling and whitespace.

Example fix

# before
selenium-manager --driver chrome-driver
# after
selenium-manager --driver chromedriver
Defensive patterns

Strategy: type-guard

Type guard

const SUPPORTED_DRIVERS: &[&str] = &["chromedriver","geckodriver","edgedriver","iedriver","safaridriver"];
fn is_supported_driver(name: &str) -> bool {
    SUPPORTED_DRIVERS.iter().any(|d| d.eq_ignore_ascii_case(name.trim()))
}
if !is_supported_driver(&driver) {
    return Err(anyhow!("invalid driver name: {driver}"));
}

Prevention

When it happens

Trigger: get_manager_by_driver(driver_name) is called with a value that eq_ignore_ascii_case matches none of the recognized driver names (lib.rs:1738-1751).

Common situations: Typo; requesting a driver Selenium Manager does not ship a manager for; extra suffixes like "chromedriver.exe".

Related errors


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