In search of an example application that uses multiple Windows in a Windows application
The Calculator automation example is great and works very well on my Windows 10 box.
The application I want to test opens a main window, followed immediately by an "Initializing" dialog which goes away once initializing is done. Then a Login Dialog opens.
When I execute
var allWindowHandles = session.WindowHandles;
I only ever get an array with one element in it, but when I try to SwitchTo that window, I get "Currently selected window has been closed"
I suspect the WindowHandle is for the main window or the Initializing window whereas I want the Login dialog.
Are there examples available that show testing of this type of application?
Any hints you have will be greatly appreciated.
Hi @chuckfitzpatricksf,
Your observation is accurate and complex launching scenarios including splash screen requires a special launching sequence. For this reason WinAppDriver supports attaching to an existing app window scenario as described in the wiki FAQ section.
@timotiusmargo How to make it using java. Sorry i am new to this. Can you help me?
Hi @Maohan1989,
In the sample given in the wiki above, the code is in C#. Nevertheless, there should be the same/similarly named objects and properties in Java that will behave the same way on WinAppDriver.
I would start with a Java Appium sample where you can successfully automate a simpler application like calculator, and then modify it to launch and attach the more complex one.
Do i need ti Install appium for running DesktopApplication?
I am not able to run my automation script by using
driver = new WindowsDriver(new URL("http://127.0.0.1:4723/"), capabilities);
instead if i use driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/"), capabilities);
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/remote/JsonException at io.appium.java_client.remote.AppiumCommandExecutor.doExecute(AppiumCommandExecutor.java:110) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:162) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600) at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) at io.appium.java_client.windows.WindowsDriver.execute(WindowsDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:142) at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:88) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:112) at io.appium.java_client.windows.WindowsDriver.(WindowsDriver.java:43) at com.desktop.automation.test.Test.main(Test.java:31) Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.JsonException at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 13 more
we handled automation of Axapta, with winapp driver, every click in this application opens up a new window. here is how we sloved it.. we have a base desktop session and then identified the new window and then made the session out of this window handle sample code if it helps you:
code behind the create child session
desktopSession = Utility.CreateNewSession(CommonTestSettings.DesktopAppId);
Assert.IsNotNull(desktopSession.SessionId);
WindowsElement axchild = desktopSession.FindElementByClassName(“”);
string axchildwindowhandle = (int.Parse(axchild.GetAttribute("NativeWindowHandle"))).ToString("x");
DesiredCapabilities appCapabilities1 = new DesiredCapabilities();
appCapabilities1.SetCapability("appTopLevelWindow", axchildwindowhandle);
Thread.Sleep(3000);
Logger.LogEnd(System.Reflection.MethodBase.GetCurrentMethod());
return new WindowsDriver<WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities1);
code behind the create child session
desktopSession = Utility.CreateNewSession(CommonTestSettings.DesktopAppId); Assert.IsNotNull(desktopSession.SessionId); WindowsElement axchild = desktopSession.FindElementByClassName(“”); string axchildwindowhandle = (int.Parse(axchild.GetAttribute("NativeWindowHandle"))).ToString("x"); DesiredCapabilities appCapabilities1 = new DesiredCapabilities(); appCapabilities1.SetCapability("appTopLevelWindow", axchildwindowhandle); Thread.Sleep(3000); Logger.LogEnd(System.Reflection.MethodBase.GetCurrentMethod()); return new WindowsDriver<WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities1);
@subhapuram How are you determining the new window? driver.WindowHandles.Last() ?