WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

Window detail once closed is lost and the it is not able to recognize when the window is opened again

Open karthikmsctcs opened this issue 7 years ago • 6 comments

I have a task in which i open a window, save the window object in a variable. Do some operations and close the window. Re open the same window, but the same window object is not able to identify the window, i need to find the elements again for the operation.

//Open a new window with name var window = session.findelementbyname(name); ///Do operations on the window //close the window //Open the same window window.displayed shows false even when the window is open. Need to have this line window = session.findelementbyname(name); to run without errors

karthikmsctcs avatar Nov 26 '19 06:11 karthikmsctcs

The don't use session.quit(). if you close the window you need to reinitialize the session.

anunay1 avatar Nov 26 '19 07:11 anunay1

Am not saying about the session. Am saying about windowselement object. that needs to be re initialized when the screen is closed and re opened.

karthikmsctcs avatar Nov 26 '19 08:11 karthikmsctcs

Yes.

anunay1 avatar Nov 26 '19 08:11 anunay1

Can we get an option that the variable holds the details and use it when the window is opened again?

karthikmsctcs avatar Nov 26 '19 08:11 karthikmsctcs

But it's not the same window. It's a new instance. In yours tests logic it's still the same window but in a logic of a tested app it's completely new window.

pm90pl avatar Nov 27 '19 07:11 pm90pl

@pm90pl is correct. If you are attempting see if the form / window is still open / displayed after it's closed you'll have to catch the exception:

            var startupFormWindowsElement = windowsApplicationRootDriver.FindElementByAccessibilityId("StartupForm");

            var isStartupFormWindowsElementDisplayed = startupFormWindowsElement.Displayed;

            // If you close the form here and run the line below, an exception will be thrown since WinAppDriver will attempt to retrieve the relevant information regarding the same window.
             isStartupFormWindowsElementDisplayed = startupFormWindowsElement.Displayed;

            // {"status":7,"value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters."}}

clintmasden avatar Dec 07 '19 00:12 clintmasden