Reputation: 1082
Before starting test execution, I have to manually start this WinAppDriver.exe.
I want to automate this task when I start executing my test cases it should start this exe and after finish it will close it.
I have tried in Java with below code but I'm not success:
Runtime runTime = Runtime.getRuntime();
String executablePath = "C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe";
Process process = runTime.exec(executablePath);
Note: I required to run it with 'Run As Administrator'
Upvotes: 4
Views: 3839
Reputation: 179
The above answers are correct but if you want to run winapp driver on specific ports then in that case you will need to use this
String command = "C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe";
List<String> commands = new ArrayList<String>();
commands.add(command);
commands.add("8888");
ProcessBuilder builder = new ProcessBuilder(commands).inheritIO();
Process p=builder.start();
p.destroy();
Here we can pass all parameters inside the list and pass this list object inside ProcessBuilder.
Default URL: http://127.0.0.1:4723
In our case URL:http://127.0.0.1:8888
Upvotes: 0
Reputation: 2000
Both worked for me without staring eclipse as Admin .
Runtime.getRuntime().exec("C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe");
Also the Sukhangad singh's answer.
String command = "C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe";
ProcessBuilder builder = new ProcessBuilder(command).inheritIO();
builder.start();
Upvotes: 2
Reputation: 76
I would suggest using ProcessBuilder class from java as is it recommended to use it after Java 5 for starting/creating processes. Below code will start the WinAppDriver.exe :
String command = "C:\Users\Administrator\WinAppDriver\WinAppDriverTool\WinAppDriver.exe";
ProcessBuilder builder = new ProcessBuilder(command).inheritIO();
startWinAppDriver = builder.start();
Hope this helps.
Upvotes: 3