Winappdriver: App with multiple windows

Created on 15 Aug 2019  路  4Comments  路  Source: microsoft/WinAppDriver

I am using Appium to drive a Windows App, it loads correctly and I can use the driver to interact with the UI Pane correctly, but it's an App that has multiple windows to go through while authenticating. Once the first window that was launched by Appium opens the next window and closes, the driver is no longer able to interact with the new window.

Is there an approach for the driver passing control to the new window so I can use the driver to interact with it?
(driver.window_handles contains the original window, and then when going to the next one, is empty)

Question

Most helpful comment

It may not be the best solution but i think it can help you out.

At first, you may create session as app 'Root'.
Whenever the login form open, you create another session base on the top level window - the login window. You continue use this session for something before login.
Whenever the second form open, the login form is closed, you create another session base on the second form and use it to do the rest.

About how to create session base on window, you may see the comment here: https://github.com/microsoft/WinAppDriver/issues/92#issuecomment-323217558

Hope it can help :)

All 4 comments

It may not be the best solution but i think it can help you out.

At first, you may create session as app 'Root'.
Whenever the login form open, you create another session base on the top level window - the login window. You continue use this session for something before login.
Whenever the second form open, the login form is closed, you create another session base on the second form and use it to do the rest.

About how to create session base on window, you may see the comment here: https://github.com/microsoft/WinAppDriver/issues/92#issuecomment-323217558

Hope it can help :)

I am not entirely certain as to what you mean by multiple windows. Multiple simultaneously open, or sequentially opened being the uncertainty.

I assume sequentially opened and closed

There is an event which initiates the sequence, it is generated somehow. Once the event occurs there is a sequence of conditions which you wish to observe. Each condition consists of a Window vanishing (either closed or no longer visible) followed by a Window becoming observable (either created or made visible). To monitor these conditions I developed two procedures (which if I have inserted them properly you will find in the file immediately below).

The procedures have not been rigorously tested. You will have to modify them for your own purposes. They are based your locating the title of the window by name. They have timeouts which must be provided as an argument (the timeouts are application specific)

findWindow.txt

I'd also recommend switching to a Desktop session to interact with the other windows and then switching back to the original session.

@khoachung89 thanks for that suggestion, I used the linked article to create the driver as root, and then have managed to create a driver for a given web element window.

Was this page helpful?
0 / 5 - 0 ratings