Search code examples
automationwinappdriver

How to start WinAppDriver programmatically in the remote machine


My test setup consist of 2 windows machines, first one test runner which will have the my test code in c# and the second one test agent machine where winappdriver is installed along with application under test.

I would like to start the winappdriver in the test agent through the C# code and the code would run on the test runner. Also, I would like to close the winappdriver once test execution is over.

How this could be done? Appreciate any lead on this.


Solution

  • For Java specific projects: You can Do it in following ways- Assumin WinAppDriver is installed in default location-i.e. C:/Program Files (x86)/Windows Application Driver

    1st:
    String command = "C:/Program Files (x86)/Windows Application Driver/WinAppDriver.exe";
    Runtime.getRuntime().exec(command);
    
    2nd:
     String command = "C:/Program Files (x86)/Windows Application Driver/WinAppDriver.exe";
     ProcessBuilder builder = new ProcessBuilder(command).inheritIO();
     Process process = builder.start();
    
    Dont forget to dispose it by-
            winDriver.close();
            winDriver.quit();
    
    or for 2nd approach-
     process.destroy();
    

    Convert them as part of you init or BeforeTest Methods as needed.