Operating system utilities for Selenium WebDriver, providing cross-platform process management and executable discovery capabilities
—
Deprecated command-line execution utilities maintained for backward compatibility. These classes are marked as deprecated and should not be used in new implementations. Use the modern ExternalProcess API instead.
Deprecated wrapper for command-line execution with environment variable management and library path configuration.
/**
* @deprecated Use ExternalProcess.Builder instead for new implementations
*/
@Deprecated
public class CommandLine {
/**
* Create command line with executable and arguments
* @param executable the executable to run
* @param args command arguments
*/
public CommandLine(String executable, String... args);
/**
* Set multiple environment variables
* @param environment map of environment variables
* @throws IllegalArgumentException if any value is null
*/
public void setEnvironmentVariables(Map<String, String> environment);
/**
* Set single environment variable
* @param name variable name (must not be null)
* @param value variable value (must not be null)
* @throws IllegalArgumentException if name or value is null
*/
public void setEnvironmentVariable(String name, String value);
/**
* Set dynamic library path for the platform
* @param newLibraryPath new library path (null values ignored)
*/
public void setDynamicLibraryPath(String newLibraryPath);
/**
* Append to existing dynamic library path
* @param extraPath path to append (null values ignored)
*/
public void updateDynamicLibraryPath(String extraPath);
/**
* Get platform-specific library path environment variable name
* @return "PATH" on Windows, "DYLD_LIBRARY_PATH" on Mac, "LD_LIBRARY_PATH" on Linux
*/
public static String getLibraryPathPropertyName();
/**
* Execute command asynchronously
*/
public void executeAsync();
/**
* Execute command and wait for completion
*/
public void execute();
/**
* Wait for process to start
* @param duration time to wait
* @param unit time unit
* @return true if process started within timeout
*/
public boolean waitForProcessStarted(long duration, TimeUnit unit);
/**
* Wait for process completion indefinitely
*/
public void waitFor();
/**
* Wait for process completion with timeout
* @param timeout timeout in milliseconds
*/
public void waitFor(long timeout);
/**
* Check if exit code is 0
* @return true if process completed successfully
*/
public boolean isSuccessful();
/**
* Get process exit code
* @return exit code of completed process
* @throws IllegalStateException if process still running
*/
public int getExitCode();
/**
* Get stdout output as string
* @return process output
*/
public String getStdOut();
/**
* Destroy the process
* @return exit code after destruction
*/
public int destroy();
/**
* Check if process is still running
* @return true if process is running
*/
public boolean isRunning();
/**
* Set input to send to process
* @param allInput input string
*/
public void setInput(String allInput);
/**
* Set working directory
* @param workingDirectory directory path
*/
public void setWorkingDirectory(String workingDirectory);
/**
* Copy output to additional stream
* @param out output stream
*/
public void copyOutputTo(OutputStream out);
/**
* Check for execution errors
*/
public void checkForError();
/**
* String representation of command and environment
* @return string representation
*/
public String toString();
}Usage Examples (Deprecated - Use ExternalProcess instead):
import org.openqa.selenium.os.CommandLine;
import java.util.HashMap;
import java.util.Map;
// Basic execution (deprecated pattern)
CommandLine cmd = new CommandLine("echo", "Hello", "World");
cmd.execute();
String output = cmd.getStdOut();
System.out.println("Output: " + output);
// Environment configuration (deprecated pattern)
CommandLine cmd = new CommandLine("java", "-jar", "myapp.jar");
cmd.setEnvironmentVariable("JAVA_OPTS", "-Xmx2g");
cmd.setDynamicLibraryPath("/opt/myapp/lib");
cmd.setWorkingDirectory("/opt/myapp");
// Asynchronous execution (deprecated pattern)
cmd.executeAsync();
boolean started = cmd.waitForProcessStarted(5, TimeUnit.SECONDS);
if (started) {
cmd.waitFor(30000); // Wait up to 30 seconds
if (cmd.isSuccessful()) {
System.out.println("Command completed successfully");
} else {
System.err.println("Command failed with exit code: " + cmd.getExitCode());
}
}Internal deprecated process management implementation used by CommandLine. This class is package-private and not intended for direct use.
/**
* @deprecated Internal implementation class - do not use directly
*/
@Deprecated
class OsProcess {
/**
* Create OS process with executable and arguments
* @param executable executable to run
* @param args command arguments
*/
public OsProcess(String executable, String... args);
/**
* Set environment variable
* @param name variable name (must not be null)
* @param value variable value (must not be null)
* @throws IllegalArgumentException if name or value is null
*/
public void setEnvironmentVariable(String name, String value);
/**
* Get unmodifiable environment variables map
* @return environment variables
*/
public Map<String, String> getEnvironment();
/**
* Execute process asynchronously
*/
public void executeAsync();
/**
* Wait for process to start
* @param duration time to wait
* @param unit time unit
* @return true if started within timeout
*/
public boolean waitForProcessStarted(long duration, TimeUnit unit);
/**
* Wait for process completion
* @throws InterruptedException if interrupted
*/
public void waitFor() throws InterruptedException;
/**
* Wait for process completion with timeout
* @param timeout timeout in milliseconds
* @throws InterruptedException if interrupted
*/
public void waitFor(long timeout) throws InterruptedException;
/**
* Check if process is running
* @return true if running
*/
public boolean isRunning();
/**
* Get exit code
* @return process exit code
* @throws IllegalStateException if still running
*/
public int getExitCode();
/**
* Check for execution errors
*/
public void checkForError();
/**
* Get stdout as string
* @return process output
*/
public String getStdOut();
/**
* Set process input
* @param allInput input string
*/
public void setInput(String allInput);
/**
* Set working directory
* @param workingDirectory directory
*/
public void setWorkingDirectory(File workingDirectory);
/**
* Copy output to stream
* @param out output stream
*/
public void copyOutputTo(OutputStream out);
/**
* Destroy process
* @return exit code
*/
public int destroy();
/**
* String representation
* @return string representation
*/
public String toString();
}For new implementations, migrate from the deprecated legacy API to the modern ExternalProcess API:
Legacy Pattern (Deprecated):
// DON'T USE - Deprecated approach
CommandLine cmd = new CommandLine("git", "status");
cmd.setEnvironmentVariable("GIT_DIR", "/path/to/repo");
cmd.setWorkingDirectory("/path/to/repo");
cmd.execute();
String output = cmd.getStdOut();Modern Pattern (Recommended):
// USE THIS - Modern approach
ExternalProcess process = ExternalProcess.builder()
.command("git", Arrays.asList("status"))
.environment("GIT_DIR", "/path/to/repo")
.directory("/path/to/repo")
.start();
boolean completed = process.waitFor(Duration.ofSeconds(30));
if (completed) {
String output = process.getOutput();
int exitCode = process.exitValue();
} else {
process.shutdown();
}Resource Management:
Error Handling:
Configuration:
Thread Safety:
Output Handling:
Install with Tessl CLI
npx tessl i tessl/maven-org-seleniumhq-selenium--selenium-os