Switch application window

Hi,

I am trying to create a test case for a Windows application to open a first window for user login then open the application’s main window.

I’m using the Windows Action Recorder to create the test case. Everything works well on the login windows, then I click my “Log in” button and I got the following error message :

Could not capture Window element
Reason :
WebDriverException

Details :

org.openqa.selenium.WebDriverException: An unknown error occurred in the remote end while processing the command. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘LAPTOP-LG’, ip: ‘10.0.75.1’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: io.appium.java_client.windows.WindowsDriver
Capabilities {app: C:\Mes Projets\CYBERG\WALNU…, javascriptEnabled: true, platform: WINDOWS, platformName: WINDOWS}
Session ID: E67613CF-7635-49DF-9ACD-7E99599E7CAE
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:46)
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.getScreenshotAs(RemoteWebDriver.java:295)
at com.kms.katalon.composer.windows.spy.WindowsInspectorController.captureScreenshot(WindowsInspectorController.java:82)
at com.kms.katalon.composer.windows.dialog.WindowsRecorderDialog$3.captureImage(WindowsRecorderDialog.java:654)
at com.kms.katalon.composer.windows.dialog.WindowsRecorderDialog$3.run(WindowsRecorderDialog.java:621)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)

If needed here are the WinAppDriver logs :

==========================================
GET /session/E67613CF-7635-49DF-9ACD-7E99599E7CAE/window_handle HTTP/1.1
Accept-Encoding: gzip
Cache-Control: no-cache
Connection: Keep-Alive
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.59 (java windows)

HTTP/1.1 200 OK
Content-Length: 84
Content-Type: application/json

{“sessionId”:“E67613CF-7635-49DF-9ACD-7E99599E7CAE”,“status”:0,“value”:“0x00010B60”}

==========================================
GET /session/E67613CF-7635-49DF-9ACD-7E99599E7CAE/source HTTP/1.1
Accept-Encoding: gzip
Cache-Control: no-cache
Connection: Keep-Alive
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.59 (java windows)

HTTP/1.1 200 OK
Content-Length: 599
Content-Type: application/json

{“sessionId”:“E67613CF-7635-49DF-9ACD-7E99599E7CAE”,“status”:0,“value”:"<?xml version=\"1.0\" encoding=\"utf-16\"?><Pane AcceleratorKey="" AccessKey="" AutomationId="" ClassName="" FrameworkId=“Win32” HasKeyboardFocus=“False” HelpText="" IsContentElement=“True” IsControlElement=“True” IsEnabled=“True” IsKeyboardFocusable=“False” IsOffscreen=“True” IsPassword=“False” IsRequiredForForm=“False” ItemStatus="" I […]

==========================================
GET /session/E67613CF-7635-49DF-9ACD-7E99599E7CAE/screenshot HTTP/1.1
Accept-Encoding: gzip
Cache-Control: no-cache
Connection: Keep-Alive
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.59 (java windows)

HTTP/1.1 500 Internal Error
Content-Length: 133
Content-Type: application/json

{“status”:13,“value”:{“error”:“unknown error”,“message”:“An unknown error occurred in the remote end while processing the command.”}}

==========================================

GET /session/E67613CF-7635-49DF-9ACD-7E99599E7CAE/window_handle HTTP/1.1
Accept-Encoding: gzip
Cache-Control: no-cache
Connection: Keep-Alive
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.59 (java windows)

HTTP/1.1 200 OK
Content-Length: 84
Content-Type: application/json

{“sessionId”:“E67613CF-7635-49DF-9ACD-7E99599E7CAE”,“status”:0,“value”:“0x00010B60”}

Hi @l.gilhard,

Can you share us the error message?

Thanks

Yes of course ! Sorry for the incomplete post (just edited), I hited Ctrl+Enter in order to break the line but the message was submitted instead.

If I click on “Refresh screen”, I have the same error. It’s like Katalon doesn’t find my application’s windows.

I guess it’s becouse the main program is an another instance. How to attach to an new window?

I found some clues in WinAppDriver FAQ (https://github.com/microsoft/WinAppDriver/wiki/Frequently-Asked-Questions):

DesktopSession.Keyboard.SendKeys(Keys.Meta + “s” + Keys.Meta); var CortanaWindow = DesktopSession.FindElementByName(“Cortana”); var CortanaTopLevelWindowHandle = CortanaWindow.GetAttribute(“NativeWindowHandle”); CortanaTopLevelWindowHandle = (int.Parse(CortanaTopLevelWindowHandle)).ToString(“x”); // Convert to Hex // Create session by attaching to Cortana top level window DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability(“appTopLevelWindow”, CortanaTopLevelWindowHandle); CortanaSession = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities); // Use the session to control Cortana CortanaSession.FindElementByAccessibilityId(“SearchTextBox”).SendKeys(“add”);

Hi @piotr.kochanek.2,

We will provide an option to attach new window in the Window record actions in v7.1.1.


Thanks, and please stay tuned.