or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

browser-management.mdbrowser-managers.mdcli-interface.mdconfiguration.mddriver-management.mdindex.md
tile.json

driver-management.mddocs/

Driver Management

Selenium Manager provides comprehensive WebDriver management including automatic driver version resolution, downloading, and caching across all supported browsers.

Driver Version Resolution

Request Driver Version

Automatically determines the appropriate driver version based on browser version and availability.

trait SeleniumManager {
    fn request_driver_version(&mut self) -> Result<String, Error>;
}

Parameters: None Returns: Result<String, Error> - The resolved driver version string Description: Analyzes browser version and available drivers to determine the best compatible driver version

Get Driver URL

Gets the download URL for the driver based on current configuration.

trait SeleniumManager {
    fn get_driver_url(&mut self) -> Result<String, Error>;
}

Parameters: None Returns: Result<String, Error> - The complete URL for downloading the driver Description: Constructs the appropriate download URL based on driver version, OS, and architecture

Driver Downloading and Installation

Download Driver

Downloads the WebDriver executable and prepares it for use.

trait SeleniumManager {
    fn download_driver(&mut self) -> Result<(), Error>;
}

Parameters: None Returns: Result<(), Error> - Success indicator Description: Downloads, extracts, and sets up the WebDriver executable in the cache directory

Get Driver Path in Cache

Retrieves the filesystem path to a cached driver.

trait SeleniumManager {
    fn get_driver_path_in_cache(&self) -> Result<PathBuf, Error>;
}

Parameters: None Returns: Result<PathBuf, Error> - Path to the cached driver executable Description: Gets the absolute path to the driver executable in the cache

Driver Information

Get Driver Name

Returns the name of the WebDriver managed by this manager.

trait SeleniumManager {
    fn get_driver_name(&self) -> &str;
}

Parameters: None Returns: &str - The driver name (e.g., "chromedriver", "geckodriver", "msedgedriver") Description: Gets the canonical name of the WebDriver this manager handles

Main Setup Method

Setup

The primary method that orchestrates the complete driver setup process.

trait SeleniumManager {
    fn setup(&mut self) -> Result<PathBuf, Error>;
}

Parameters: None Returns: Result<PathBuf, Error> - Path to the ready-to-use driver executable Description: Performs complete setup including browser discovery, driver version resolution, downloading if needed, and returns the path to the executable

Usage Examples

Basic Driver Setup

use selenium_manager::{get_manager_by_browser, SeleniumManager};
use anyhow::Result;

fn setup_chrome_driver() -> Result<()> {
    let mut manager = get_manager_by_browser("chrome".to_string())?;
    
    // Complete setup process
    let driver_path = manager.setup()?;
    
    println!("ChromeDriver ready at: {}", driver_path.display());
    
    // Use driver_path with your WebDriver client
    Ok(())
}

Manual Driver Version Resolution

use selenium_manager::{get_manager_by_driver, SeleniumManager};
use anyhow::Result;

fn resolve_driver_manually() -> Result<()> {
    let mut manager = get_manager_by_driver("geckodriver".to_string())?;
    
    // Get the recommended driver version
    let driver_version = manager.request_driver_version()?;
    println!("Recommended GeckoDriver version: {}", driver_version);
    
    // Get download URL
    let download_url = manager.get_driver_url()?;
    println!("Download URL: {}", download_url);
    
    // Download the driver
    manager.download_driver()?;
    
    // Get path to downloaded driver
    let driver_path = manager.get_driver_path_in_cache()?;
    println!("Driver cached at: {}", driver_path.display());
    
    Ok(())
}

Check Cached Drivers

use selenium_manager::{get_manager_by_browser, SeleniumManager};
use anyhow::Result;

fn check_cached_driver() -> Result<()> {
    let manager = get_manager_by_browser("edge".to_string())?;
    
    // Check if driver is already cached
    match manager.get_driver_path_in_cache() {
        Ok(path) => {
            println!("EdgeDriver already cached at: {}", path.display());
        }
        Err(_) => {
            println!("EdgeDriver not found in cache, will need to download");
        }
    }
    
    Ok(())
}

Complete Workflow with Error Handling

use selenium_manager::{get_manager_by_browser, SeleniumManager};
use anyhow::Result;

fn complete_driver_workflow() -> Result<()> {
    let mut manager = get_manager_by_browser("firefox".to_string())?;
    
    println!("Setting up {} driver...", manager.get_driver_name());
    
    // Check if we can resolve a driver version
    match manager.request_driver_version() {
        Ok(version) => {
            println!("Using driver version: {}", version);
            
            // Attempt setup
            match manager.setup() {
                Ok(driver_path) => {
                    println!("Driver setup complete: {}", driver_path.display());
                    
                    // Verify the driver file exists and is executable
                    if driver_path.exists() {
                        println!("Driver verification successful");
                    } else {
                        println!("Warning: Driver file not found after setup");
                    }
                }
                Err(e) => {
                    eprintln!("Driver setup failed: {}", e);
                    return Err(e);
                }
            }
        }
        Err(e) => {
            eprintln!("Failed to resolve driver version: {}", e);
            return Err(e);
        }
    }
    
    Ok(())
}

Supported WebDrivers

ChromeDriver

  • Driver name: chromedriver
  • Browser compatibility: Chrome, Chromium
  • Version resolution: Based on Chrome version via Chrome for Testing API
  • Platforms: Windows, macOS, Linux (x64, ARM64)

GeckoDriver

  • Driver name: geckodriver
  • Browser compatibility: Firefox, Firefox ESR
  • Version resolution: Latest compatible version from Mozilla releases
  • Platforms: Windows, macOS, Linux (x64, ARM64)

EdgeDriver

  • Driver name: msedgedriver
  • Browser compatibility: Microsoft Edge, WebView2
  • Version resolution: Based on Edge version via Microsoft API
  • Platforms: Windows, macOS, Linux (x64, ARM64)

IEDriver

  • Driver name: IEDriverServer
  • Browser compatibility: Internet Explorer
  • Version resolution: Latest stable version
  • Platforms: Windows only (x32, x64)

SafariDriver

  • Driver name: safaridriver
  • Browser compatibility: Safari
  • Version resolution: System-provided driver
  • Platforms: macOS only

Caching Behavior

  • Cache location: ~/.cache/selenium/ (configurable)
  • Cache structure: Organized by browser, version, OS, and architecture
  • TTL (Time-to-Live): 1 hour by default for version metadata
  • Cache validation: Automatic cleanup and re-download when needed

Mirror Support

Selenium Manager supports custom mirror URLs for driver downloads:

// Example with custom mirror
let config = ManagerConfig {
    driver_mirror_url: "https://npm.taobao.org/mirrors/chromedriver/".to_string(),
    ..Default::default()
};

Error Handling

Driver management operations return detailed error information:

  • VersionResolutionFailed: Unable to determine compatible driver version
  • DownloadFailed: Network issues or invalid URLs during download
  • ExtractionFailed: Issues extracting downloaded driver archives
  • CacheError: Problems accessing or writing to cache directory
  • UnsupportedPlatform: Driver not available for current OS/architecture
  • BrowserNotFound: Cannot determine browser version for driver compatibility