WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

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

Open KiranBehara opened this issue 7 years ago • 8 comments

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; }

KiranBehara avatar Mar 29 '19 13:03 KiranBehara

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.

yodurr avatar Apr 02 '19 16:04 yodurr

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");

KiranBehara avatar Apr 03 '19 09:04 KiranBehara

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());

KiranBehara avatar Apr 03 '19 09:04 KiranBehara

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);

balab335 avatar Apr 25 '19 03:04 balab335

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

sseenivasan89 avatar Aug 27 '19 08:08 sseenivasan89

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

rkunamneni19 avatar Oct 15 '19 18:10 rkunamneni19

  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);

rkunamneni19 avatar Oct 15 '19 18:10 rkunamneni19

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();

JDCain avatar Oct 28 '19 13:10 JDCain