Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:SeleniumHQ Selenium SeleniumManager GetBinaryPaths

From Leeroopedia
Knowledge Sources
Domains Browser_Automation, Dependency_Management, Binary_Resolution
Last Updated 2026-02-11 00:00 GMT

Overview

Concrete tool for resolving browser and driver binary paths provided by the Selenium Manager Java wrapper.

Description

The SeleniumManager class is a Java singleton that wraps the Selenium Manager Rust binary. It extracts the platform-appropriate binary from the JAR (Windows, macOS, or Linux), caches it in ~/.cache/selenium (configurable via the SE_CACHE_PATH environment variable), and provides the getBinaryPaths() method to invoke it with CLI arguments. The Rust binary handles the actual browser detection, version matching, downloading, and caching. The Java wrapper handles process execution via ExternalProcess, JSON output parsing via SeleniumManagerOutput, and logging integration. The binary path can be overridden by setting the SE_MANAGER_PATH environment variable. System properties prefixed with SE_ are forwarded as environment variables to the Selenium Manager process.

Usage

This class is invoked automatically by DriverFinder during WebDriver session creation. Direct usage is rarely needed, but it can be useful for pre-downloading drivers in CI setup scripts or for debugging driver resolution issues.

Code Reference

Source Location

  • Repository: Selenium
  • File: java/src/org/openqa/selenium/manager/SeleniumManager.java
  • Lines: L60-309
  • Output model: java/src/org/openqa/selenium/manager/SeleniumManagerOutput.java (L26-216)

Signature

@Beta
public class SeleniumManager {
    // Singleton access (double-checked locking)
    public static SeleniumManager getInstance();

    // Main API method
    public Result getBinaryPaths(List<String> arguments);
    // Appends "--language-binding java --output json" to the arguments
    // Appends "--debug" when log level is FINE or below
    // Returns: SeleniumManagerOutput.Result with driverPath, browserPath, code, message
}

// Result data class
public static class Result {
    public int getCode();
    public String getMessage();
    public String getDriverPath();
    public String getBrowserPath();
}

Import

import org.openqa.selenium.manager.SeleniumManager;
import org.openqa.selenium.manager.SeleniumManagerOutput;

I/O Contract

Inputs

Name Type Required Description
arguments List<String> Yes CLI arguments: --browser, --browser-version, --driver, etc.

Outputs

Name Type Description
result.getDriverPath() String Absolute path to the resolved driver binary
result.getBrowserPath() String Absolute path to the resolved browser binary
result.getMessage() String Status message from Selenium Manager
result.getCode() int Exit code (0 for success)

Usage Examples

Automatic Usage (Transparent)

// SeleniumManager is invoked automatically when creating a driver
// No explicit call needed - DriverFinder handles this
ChromeDriver driver = new ChromeDriver(); // SM resolves chromedriver automatically

Explicit Usage (Advanced)

import org.openqa.selenium.manager.SeleniumManager;
import org.openqa.selenium.manager.SeleniumManagerOutput;

// Get the singleton instance
SeleniumManager sm = SeleniumManager.getInstance();

// Resolve paths for Chrome
List<String> args = List.of("--browser", "chrome");
SeleniumManagerOutput.Result result = sm.getBinaryPaths(args);

System.out.println("Driver: " + result.getDriverPath());
System.out.println("Browser: " + result.getBrowserPath());

Configuring Cache Path

// Set cache path via system property before driver creation
System.setProperty("SE_CACHE_PATH", "/opt/selenium/cache");

// Or set SE_MANAGER_PATH to use a specific Selenium Manager binary
System.setProperty("SE_MANAGER_PATH", "/usr/local/bin/selenium-manager");

ChromeDriver driver = new ChromeDriver();

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment