Implementation:SeleniumHQ Selenium ExecutableFinder
| Knowledge Sources | |
|---|---|
| Domains | WebDriver, Infrastructure |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
ExecutableFinder locates executables on the filesystem by scanning the system PATH and applying platform-specific conventions for file extensions and additional search paths.
Description
ExecutableFinder is a utility class in the org.openqa.selenium.os package that searches for an executable by name. It first checks if the given name is directly executable (as a file path), then on Windows also tries appending .exe. It then scans all directories listed in the PATH environment variable (case-insensitive lookup for the variable name), trying each directory with platform-appropriate file endings: on Windows it checks .cmd, .exe, .com, and .bat extensions in addition to the bare name; on other platforms it checks only the bare name. On macOS, it additionally reads /etc/paths to include system-defined path directories that may not be in the shell's PATH variable. A file is considered executable if it exists, is not a directory, and has the execute permission.
Usage
Use ExecutableFinder to locate browser driver executables (such as chromedriver, geckodriver, msedgedriver) or other tools on the system PATH before launching them with ExternalProcess. This is used internally by Selenium to resolve driver binary locations.
Code Reference
Source Location
- Repository: SeleniumHQ_Selenium
- File: java/src/org/openqa/selenium/os/ExecutableFinder.java
Signature
public class ExecutableFinder {
public @Nullable String find(String named)
}
Import
import org.openqa.selenium.os.ExecutableFinder;
I/O Contract
| Method | Input | Output | Description |
|---|---|---|---|
find(String named) |
named: name or path of the executable to find |
@Nullable String -- absolute path to the executable, or null if not found |
Searches for the executable in the following order: (1) direct path check, (2) direct path with .exe on Windows, (3) each PATH directory with platform-specific endings, (4) macOS /etc/paths directories. Returns the first match or null.
|
| Platform | File Endings Checked | Additional Search Paths |
|---|---|---|
| Windows | "", ".cmd", ".exe", ".com", ".bat" |
none |
| macOS | "" |
Directories listed in /etc/paths
|
| Linux/Other | "" |
none |
Usage Examples
import org.openqa.selenium.os.ExecutableFinder;
ExecutableFinder finder = new ExecutableFinder();
// Find chromedriver on the PATH
String chromedriverPath = finder.find("chromedriver");
if (chromedriverPath != null) {
System.out.println("Found chromedriver at: " + chromedriverPath);
} else {
System.out.println("chromedriver not found on PATH");
}
// Find geckodriver
String geckodriverPath = finder.find("geckodriver");
// On Windows, .exe extension is optional
String edgedriverPath = finder.find("msedgedriver");
// Will also check for msedgedriver.exe, msedgedriver.cmd, etc.
Related Pages
- SeleniumHQ_Selenium_ExternalProcess -- Launches executables found by ExecutableFinder as managed processes
- SeleniumHQ_Selenium_PortProber -- Finds free ports for driver processes