licanhua / YWinAppDriver

A open source project provides WinAppDriver compatible functionality
MIT License
49 stars 10 forks source link

Element in dropdown menu not found #14

Closed Jteve-Sobs closed 2 years ago

Jteve-Sobs commented 3 years ago

Hi,

appreciate your work and I would like to use YWinAppDriver in my project.

In my project I just replaced the WinAppDriver and gave it a go. However when selecting an entry in a dropdown menu (which was opened in a previous click) this error occurs: "Didn't found the element in cache" and the program fails. While debugging the value of the variable is not null, as seen in this if statement where the error is thrown: if (element != null) { element.Click(); // error occurs here }

Is it also possible to implement the screenshot feature of Selenium ? Would be very helpful.

Best regards and thanks

licanhua commented 3 years ago

Are you using the newest version? I didn't see below code.

if (element != null)
{
element.Click();
}

For the menu, if you open it and close it, although the name is the same, you need to locate the element again. To reduce the cache size, the logic is like this:

  1. You located a element, and YWinAppDrive cached it. YWinAppDriver hold an reference to the UIA element
  2. The element changed(like you close the menu, then open again). The actual UIA element is changed too although it looks like the same
  3. You use the old reference to click, then YWinAppDriver report Stale Element and remove the element from the cache
  4. If you use the old reference to click again, then YWinAppDriver report 'Didn't found the element in cache'
licanhua commented 3 years ago

I already added the screenshot feature

licanhua commented 3 years ago

@Jteve-Sobs did you still see the problem in latest version?