Open aristotelos opened 10 months ago
This may be a bug in the Windows UIA3 implementation itself, so that it is impossible to fix in FlaUI. I found the same issue exists in WinAppDriver and the workaround is to re-retrieve the menu item after it has been clicked:
await TestFixture.cam2DDriver.$(`[name="View"]`).click();
// WinAppDriver doesn't find $(`[name="Toolbars"]`) straight away
await TestFixture.cam2DDriver.$(`[name="View"]`).$(`[name="Toolbars"]`).click();
// WinAppDriver doesn't find $(`[name="${toolbar_name}"]`) straight away
await TestFixture.cam2DDriver.$(`[name="View"]`).$(`[name="Toolbars"]`).$(`[name="${toolbar_name}"]`).click();
I have experienced this issue using raw UIAv2 and UIAv3 outside of FlaUI, unfortunately. My guess is that this has something to do with claiming ownership of the windows that menus create but either way it can't be fixed in FlaUI directly.
Describe the bug I have some code that finds a menu item from the current main window. I have observed the following:
Window
returned byGetMainWindow
and callFindFirstDescendant
on it, it returnsnull
GetMainWindow
again after the menu has been clicked and callFindFirstDescendant
on that newWindow
instance returned, it returns the menu itemThe element tree was as following:
Window > Menu Bar > Menu Item (clicked) > Menu > Menu Item (to be found and clicked)
Code snippets This was discovered while working on a FlaUI WebDriver implementation. Here is the part that refreshes the
Window
all the time to work around this issue:https://github.com/FlaUI/FlaUI/blob/b1f61c11489e8c3ea40be38628f4d15bcc1c7a1d/src/FlaUI.WebDriver/Session.cs#L49-L54
Additional context Using UIA3.