CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-seleniumhq-selenium--selenium-os

Operating system utilities for Selenium WebDriver, providing cross-platform process management and executable discovery capabilities

Pending
Overview
Eval results
Files

executable-finder.mddocs/

Executable Discovery

Cross-platform utility for finding executables on the system PATH with automatic handling of platform-specific file extensions and search paths.

Capabilities

ExecutableFinder Class

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());
    }
}

Search Algorithm

The ExecutableFinder implements a comprehensive search strategy that handles platform differences automatically:

Search Order:

  1. Direct Path Check: If the provided name is already an absolute or relative path to an executable file
  2. Windows Extension Check: On Windows, automatically try adding .exe extension
  3. PATH Environment Scanning: Search each directory in the PATH environment variable
  4. Platform-Specific Extensions: Try all appropriate extensions for the current platform
  5. macOS Specific Paths: On macOS, additionally search paths defined in /etc/paths

Platform-Specific Extensions:

  • Windows: "", .cmd, .exe, .com, .bat
  • Unix/Linux/macOS: "" (no extension)

Environment Variable Handling:

  • Searches PATH environment variable (case-insensitive lookup)
  • Uses File.pathSeparator for splitting PATH entries (; on Windows, : on Unix)
  • Handles missing or empty PATH gracefully

macOS Enhancement:

  • Reads /etc/paths file for additional system paths
  • Gracefully handles missing /etc/paths file
  • Each line in /etc/paths is treated as an additional search directory

File System Checks

The finder performs comprehensive checks to ensure discovered files are actually executable:

Validation Criteria:

  • File must exist on the file system
  • Must not be a directory
  • Must have executable permissions (File.canExecute())

Error Handling:

  • Returns null if no executable found (never throws exceptions)
  • Handles I/O errors gracefully during file system access
  • Manages permissions errors when checking executability

Cross-Platform Considerations:

  • Respects platform-specific permission models
  • Handles symbolic links appropriately
  • Works with both absolute and relative paths in PATH entries

Integration with Process Management

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

docs

executable-finder.md

index.md

legacy-process.md

modern-process.md

tile.json