Start WinAppDriver Programmatically Java

Profile picture for user devraj
Submitted by devraj on

You can launch WinAppDriver programmatically in Java using several ways. Two approach we will discuss today ProcessBuilder and RunTime Class:

Method 1: Launch WinAppDriver using Process Builder

Process builder is a class used to create operating system processes.

// WinAppDriver path
String winAppDriverPath = "C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe"; 

// Process provides control of native processes started by ProcessBuilder.start and Runtime.exec
Process p;
// Launch WinAppDriver
public void launchWinAppDriver() throws IOException
    // List containing the WinAppDriver path and its arguments
    // This list will be accepted by ProcessBuilder
     List<String> command = new ArrayList<String>();
    // Add Path for WinAppDriver
    // Port for WinAppDriver
    // inheritIO - Sets the source and destination for subprocess standard I/O to be the same as those of the current Java process.
    ProcessBuilder builder = new ProcessBuilder(command).inheritIO();

    // Start method creates a new process instance 
    p = builder.start();	
// Terminate WinAppDriver Process
public void close()

Method 2: Launch WinAppDriver using Run Time Class

String winAppDriverPath = "C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe";

public void LaunchRuntime() throws IOException