Operating system utilities for Selenium WebDriver, providing cross-platform process management and executable discovery capabilities
—
Cross-platform utility for finding executables on the system PATH with automatic handling of platform-specific file extensions and search paths.
Locates executables by scanning the file system and PATH environment variable, with intelligent handling of platform-specific executable extensions and search locations.
public class ExecutableFinder {
/**
* Find executable by scanning file system and PATH
* @param named the name of the executable to find
* @return absolute path to executable, or null if not found
*/
public String find(String named);
}Usage Examples:
import org.openqa.selenium.os.ExecutableFinder;
ExecutableFinder finder = new ExecutableFinder();
// Find browser drivers
String chromeDriver = finder.find("chromedriver");
String geckoDriver = finder.find("geckodriver");
String edgeDriver = finder.find("msedgedriver");
// Find system utilities
String gitPath = finder.find("git");
String pythonPath = finder.find("python");
String javacPath = finder.find("javac");
if (chromeDriver != null) {
System.out.println("ChromeDriver found at: " + chromeDriver);
} else {
System.err.println("ChromeDriver not found on PATH");
}
// Use with ExternalProcess
if (gitPath != null) {
ExternalProcess process = ExternalProcess.builder()
.command(gitPath, Arrays.asList("--version"))
.start();
if (process.waitFor(Duration.ofSeconds(5))) {
System.out.println("Git version: " + process.getOutput().trim());
}
}The ExecutableFinder implements a comprehensive search strategy that handles platform differences automatically:
Search Order:
.exe extension/etc/pathsPlatform-Specific Extensions:
"", .cmd, .exe, .com, .bat"" (no extension)Environment Variable Handling:
PATH environment variable (case-insensitive lookup)File.pathSeparator for splitting PATH entries (; on Windows, : on Unix)macOS Enhancement:
/etc/paths file for additional system paths/etc/paths file/etc/paths is treated as an additional search directoryThe finder performs comprehensive checks to ensure discovered files are actually executable:
Validation Criteria:
File.canExecute())Error Handling:
null if no executable found (never throws exceptions)Cross-Platform Considerations:
ExecutableFinder is commonly used with process management classes to locate executables before launching:
import org.openqa.selenium.os.ExecutableFinder;
import org.openqa.selenium.os.ExternalProcess;
// Pattern: Locate then execute
ExecutableFinder finder = new ExecutableFinder();
String executable = finder.find("my-tool");
if (executable != null) {
ExternalProcess process = ExternalProcess.builder()
.command(executable, Arrays.asList("arg1", "arg2"))
.start();
// ... manage process
} else {
throw new IllegalStateException("Required executable 'my-tool' not found on PATH");
}
// Legacy API integration (deprecated)
String driverPath = finder.find("chromedriver");
if (driverPath != null) {
CommandLine cmd = new CommandLine(driverPath, "--port=9515");
cmd.execute();
}This pattern ensures robust executable discovery before attempting to launch processes, providing clear error messages when required tools are not available in the environment.
Install with Tessl CLI
npx tessl i tessl/maven-org-seleniumhq-selenium--selenium-os