Winappdriver: How to close the application under test & WinAppDriver after test case execution gets completed

Created on 29 Mar 2019  路  8Comments  路  Source: microsoft/WinAppDriver

I am using below code after completion of my test case, it is getting called but the WAD & application is not getting closed.

// Close the application and delete the session
if (session != null)
{
session.Quit();
session = null;
}

Most helpful comment

what type of application is it?

Try adding a session.Close(); before calling Quit();

Also, when you launch WinAppDriver you can pass /forcequit and see if that helps with closing the application at the end of the session.

All 8 comments

what type of application is it?

Try adding a session.Close(); before calling Quit();

Also, when you launch WinAppDriver you can pass /forcequit and see if that helps with closing the application at the end of the session.

Thanks session.Close() is working
Is it possible to close WinAppDriver automatically after test script run completes?

Am starting the WinAppDriver automatically from the test script in ClassInitialize(TestContext context) method by calling Process.Start("..........................\WinAppDriver.exe");

Right now am closing it by calling the below line of code. Let me know if there are any other default methods available.
Array.ForEach(Process.GetProcessesByName("WinAppDriver"), x => x.Kill());

Hi guys,
Can you please help me, how Can we start Win App Driver.exe thru java code(No Manual Intervention)
Process.Start("..........................\WinAppDriver.exe"); This line doesn't works for me.

Please find the code,which i am using
ProcessBuilder process = new ProcessBuilder("C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe");
Process start = process.start();
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
CalculatorSession = new WindowsDriver(new URL("http://127.0.0.1:4723"), capabilities);
CalculatorSession.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);

Please try this
ProcessBuilder process = new ProcessBuilder(".......\WinAppDriver.exe").start();

Create a bat file and then call that file in your script..

  1. create a .bat file with filepath of winappdriver.exe..

    Start C:\"Program Files (x86)"\"Windows Application Driver"\WinAppDriver.exe

    save it as "yourfile.bat" file
    2.in your BeforeClass write below three lines code..
    Runtime runTime = Runtime.getRuntime();
    String executablePath = "yourfile.bat";
    Process process = runTime.exec(executablePath);

This format works for me. WriteLine sends 'enter' to the console window to close it.

       var si = new ProcessStartInfo
        {
            FileName = pathtowinappdriver,
            RedirectStandardInput = true,            
        };

        var DriverProcess= Process.Start(si);

        //do testing

        DriverProcess.StandardInput.WriteLine("q");
        DriverProcess.WaitForExit();
Was this page helpful?
0 / 5 - 0 ratings

Related issues

quincycs picture quincycs  路  3Comments

didhddldlq picture didhddldlq  路  3Comments

bharathp666 picture bharathp666  路  3Comments

SimonKirkhamCL4U picture SimonKirkhamCL4U  路  3Comments

Blank517 picture Blank517  路  4Comments