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

configuration.mddocs/

Configuration

Selenium Manager provides comprehensive configuration options through the ManagerConfig struct, environment variables, and configuration files. Configuration controls all aspects of browser and driver management behavior.

ManagerConfig Structure

The main configuration structure for Selenium Manager.

pub struct ManagerConfig {
    pub cache_path: String,
    pub fallback_driver_from_cache: bool,
    pub browser_version: String,
    pub driver_version: String,
    pub browser_path: String,
    pub driver_mirror_url: String,
    pub browser_mirror_url: String,
    pub os: String,
    pub arch: String,
    pub proxy: String,
    pub timeout: u64,
    pub ttl: u64,
    pub offline: bool,
    pub force_browser_download: bool,
    pub avoid_browser_download: bool,
    pub language_binding: String,
    pub selenium_version: String,
    pub avoid_stats: bool,
    pub skip_driver_in_path: bool,
    pub skip_browser_in_path: bool,
}

Default Configuration

Creates a default configuration for a specific browser and driver.

impl ManagerConfig {
    pub fn default(browser_name: &str, driver_name: &str) -> ManagerConfig;
}

Parameters:

  • browser_name: &str - Name of the browser
  • driver_name: &str - Name of the driver

Returns: ManagerConfig - Default configuration with sensible defaults

Configuration Fields

Cache and Storage

cache_path: String

  • Description: Directory for cached drivers and metadata
  • Default: ~/.cache/selenium/
  • Example: /home/user/.cache/selenium/

fallback_driver_from_cache: bool

  • Description: Use cached driver if browser version cannot be determined
  • Default: false

Version Control

browser_version: String

  • Description: Target browser version or channel
  • Values: Version number, "stable", "beta", "dev", "canary", "nightly", "esr"
  • Example: "119.0.6045.105", "stable"

driver_version: String

  • Description: Specific driver version to use
  • Example: "119.0.6045.105", "0.33.0"

Path Configuration

browser_path: String

  • Description: Explicit path to browser executable
  • Example: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"

Mirror URLs

driver_mirror_url: String

  • Description: Custom mirror URL for driver downloads
  • Example: "https://npm.taobao.org/mirrors/chromedriver/"

browser_mirror_url: String

  • Description: Custom mirror URL for browser downloads
  • Example: "https://registry.npmmirror.com/-/binary/chromium-browser-snapshots/"

System Configuration

os: String

  • Description: Target operating system
  • Values: "windows", "linux", "macos"
  • Default: Auto-detected

arch: String

  • Description: Target system architecture
  • Values: "x32", "x64", "arm64"
  • Default: Auto-detected

Network Configuration

proxy: String

  • Description: HTTP proxy URL for network requests
  • Example: "https://proxy.example.com:8080"

timeout: u64

  • Description: Network request timeout in seconds
  • Default: 300

ttl: u64

  • Description: Time-to-live for cached metadata in seconds
  • Default: 3600

offline: bool

  • Description: Disable network requests, use cache only
  • Default: false

Download Behavior

force_browser_download: bool

  • Description: Download browser even if already installed
  • Default: false

avoid_browser_download: bool

  • Description: Never download browsers, use system-installed only
  • Default: false

Discovery Control

skip_driver_in_path: bool

  • Description: Ignore drivers found in system PATH
  • Default: false

skip_browser_in_path: bool

  • Description: Ignore browsers found in system PATH
  • Default: false

Analytics and Integration

language_binding: String

  • Description: Selenium language binding for statistics
  • Values: "Java", "JavaScript", "Python", "DotNet", "Ruby"

selenium_version: String

  • Description: Selenium version for compatibility tracking
  • Example: "4.15.0"

avoid_stats: bool

  • Description: Disable usage statistics collection
  • Default: false

Configuration Enums

Operating System

pub enum OS {
    WINDOWS,
    MACOS,
    LINUX,
}

impl OS {
    pub fn is(&self, os: &str) -> bool;
}

Architecture

pub enum ARCH {
    X32,
    X64,
    ARM64,
}

impl ARCH {
    pub fn is(&self, arch: &str) -> bool;
}

Configuration Keys

String Configuration Keys

pub struct StringKey(pub Vec<&str>, pub &str);

impl StringKey {
    pub fn get_value(&self) -> String;
}

Integer Configuration Keys

pub struct IntegerKey(pub &str, pub u64);

impl IntegerKey {
    pub fn get_value(&self) -> u64;
}

Boolean Configuration Keys

pub struct BooleanKey(pub &str, pub bool);

impl BooleanKey {
    pub fn get_value(&self) -> bool;
}

Usage Examples

Basic Configuration

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

fn basic_configuration() -> Result<()> {
    // Create default configuration
    let config = ManagerConfig::default("chrome", "chromedriver");
    
    // Create manager and apply configuration
    let mut manager = get_manager_by_browser("chrome".to_string())?;
    manager.set_config(config);
    
    let driver_path = manager.setup()?;
    println!("Driver ready at: {}", driver_path.display());
    Ok(())
}

Custom Configuration

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

fn custom_configuration() -> Result<()> {
    let mut config = ManagerConfig::default("firefox", "geckodriver");
    
    // Customize configuration
    config.browser_version = "esr".to_string();
    config.cache_path = "/tmp/selenium-cache".to_string();
    config.timeout = 600;
    config.offline = false;
    config.force_browser_download = true;
    
    let mut manager = get_manager_by_browser("firefox".to_string())?;
    manager.set_config(config);
    
    let driver_path = manager.setup()?;
    println!("Firefox ESR driver ready at: {}", driver_path.display());
    Ok(())
}

Proxy Configuration

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

fn proxy_configuration() -> Result<()> {
    let mut config = ManagerConfig::default("edge", "msedgedriver");
    
    // Configure proxy
    config.proxy = "https://proxy.company.com:8080".to_string();
    config.timeout = 900; // Longer timeout for proxy
    
    let mut manager = get_manager_by_browser("edge".to_string())?;
    manager.set_config(config);
    
    let driver_path = manager.setup()?;
    println!("Edge driver ready at: {}", driver_path.display());
    Ok(())
}

Mirror Configuration

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

fn mirror_configuration() -> Result<()> {
    let mut config = ManagerConfig::default("chrome", "chromedriver");
    
    // Use Chinese mirrors
    config.driver_mirror_url = "https://npm.taobao.org/mirrors/chromedriver/".to_string();
    config.browser_mirror_url = "https://npm.taobao.org/mirrors/chromium-browser-snapshots/".to_string();
    
    let mut manager = get_manager_by_browser("chrome".to_string())?;
    manager.set_config(config);
    
    let driver_path = manager.setup()?;
    println!("Driver ready at: {}", driver_path.display());
    Ok(())
}

Offline Mode

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

fn offline_configuration() -> Result<()> {
    let mut config = ManagerConfig::default("chrome", "chromedriver");
    
    // Enable offline mode
    config.offline = true;
    config.fallback_driver_from_cache = true;
    
    let mut manager = get_manager_by_browser("chrome".to_string())?;
    manager.set_config(config);
    
    // This will only use cached drivers/browsers
    match manager.setup() {
        Ok(driver_path) => {
            println!("Using cached driver at: {}", driver_path.display());
        }
        Err(e) => {
            println!("No cached driver available: {}", e);
        }
    }
    
    Ok(())
}

Environment Variables

Configuration can be set via environment variables with the SE_ prefix:

  • SE_CACHE_PATHcache_path
  • SE_BROWSER_VERSIONbrowser_version
  • SE_DRIVER_VERSIONdriver_version
  • SE_BROWSER_PATHbrowser_path
  • SE_PROXYproxy
  • SE_TIMEOUTtimeout
  • SE_TTLttl
  • SE_OFFLINEoffline
  • SE_FORCE_BROWSER_DOWNLOADforce_browser_download
  • SE_AVOID_BROWSER_DOWNLOADavoid_browser_download
  • SE_AVOID_STATSavoid_stats
  • SE_SKIP_DRIVER_IN_PATHskip_driver_in_path
  • SE_SKIP_BROWSER_IN_PATHskip_browser_in_path

Configuration File

Configuration can be stored in ~/.cache/selenium/se-config.toml:

cache_path = "/custom/cache/path"
browser_version = "stable"
timeout = 600
offline = false
avoid_stats = true

[proxy]
url = "https://proxy.example.com:8080"

[mirrors]
driver_url = "https://custom-mirror.com/drivers/"
browser_url = "https://custom-mirror.com/browsers/"

Configuration Precedence

Configuration values are resolved in this order (highest to lowest priority):

  1. Command-line arguments (CLI only)
  2. Programmatic configuration (API usage)
  3. Environment variables (SE_* prefix)
  4. Configuration file (~/.cache/selenium/se-config.toml)
  5. Default values