WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

Refresh elements tree in Windows

Open vberesnev opened this issue 6 years ago • 8 comments

Hello!

When I open windows calculator in Inspect, I get elements for showing "calculator mode" (for example, "engeener mode"). After I change mode (to "programmer") in Inspect I still see elements for "engeener mode". For update elements tree, I need click to button "Refresh". After that I will see elements for "programmer mode"

It is example, I am using some app, which opens user controls for each menu items (like calculator).

So, my question: How I can "refresh" elements tree in my code for get access to elements after change user control. I am using Win App Driver 1.2

I have tried this:

_windowDriver.Navigate().Refresh(); //exception

and this

_windowDriver.SwitchTo().Window(_windowDriver.WindowHandles.First()); // no success result

Thank you so much!

vberesnev avatar Jun 03 '20 16:06 vberesnev

There is no refresh API supported WAD, u need to read it again.

anunay1 avatar Jun 04 '20 12:06 anunay1

There is no refresh API supported WAD, u need to read it again.

Thank you for your answer. Please, tell me what do you mean? You mean, that I should to kill WebAppDriver server, start it again, attach Appium to new WAD server and return new instance of WindowsDriver < WindowsElement > ? Can you give me some code example please?

vberesnev avatar Jun 04 '20 15:06 vberesnev

Got the same problem in my app. Inspect.exe sees previous page when I use pagination inside my app. New page tree becomes available only after I perform refresh in Inspector window. It is strange that WinAppDriver doesn't have an option to refresh the application tree and reload elements since it's widely used thing.

splekhan avatar Jun 09 '20 10:06 splekhan

There is no refresh API supported WAD, u need to read it again.

What do you mean by reading it again? To create new driver session? Looking for webElement again doesn't do the trick since WAD is searching it in the old pane which was not refreshed.

splekhan avatar Jun 09 '20 11:06 splekhan

Discussing of this issue on the page https://github.com/microsoft/WinAppDriver/issues/1161

vberesnev avatar Jun 09 '20 14:06 vberesnev

+1 to this issue!

The whole conversation may be found on the page #1161 In order to reload application panes tree I had to create new driver instance and reswitch it to an existing window. Is there any chance to implement driver.refresh() method which would do the same as "Refresh" button in Inspect.exe?

splekhan avatar Jun 09 '20 15:06 splekhan

The Refresh would be extremely helpful.

cgetty12 avatar Jun 12 '20 14:06 cgetty12

I also miss a refresh functionality (with condition to keep the element IDs of still known GUI elements).

My tests with a WPF application on Windows often fail, because WinAppDriver often doesn't detect the current application state. Previously shown elements are still available (but with hidden state). The new shown elements can not be detected immediately. Sometimes they became detectable when changing the window size or clicking around in the GUI. But this not always helps to trigger a refresh of WinAppDriver. In such situations even the tool Inspect fails to detect the new shown elements. After doing some actions, Inspect can detect them again (in most cases, but not always).

In general the elements are detectable by WinAppDriver and Inspect. Only when WinAppDriver already queried the GUI and then the GUI changes, the detection can fail. So some parts of the visual tree can't be queried.

To restart WinAppDriver during a test is no option for me, because then the element IDs are gone. (I use it to implement complete user stories, which performs several steps with the GUI.)

It's so annoying and disturbing that this behaviour happens so often. I would like to have stable tests, which can work without somebody looking to it and restart the failed tests manually. Unfortunately I didn't find a solution for that until now.

I suppose it's a kind of bug, that changed GUIs aren't detected correctly. A forced refresh / re-read of the GUI state should solve the problem. But I don't know if this is a bug of WinAppDriver or of the underlaying Windows Automation interface.

Beautyod avatar Dec 11 '20 12:12 Beautyod