WinAppDriver
WinAppDriver copied to clipboard
WinAppDriver FindElementsByXPath sometimes fails when the singular form succeeds (and vice versa).
This is something I see a lot, but without any common pattern I'm able to infer. The exact same XPath, when used in the singular FindElementByXPath
version works, whereas it returns no results when used in the plural version FindElementsByXPath
. In other cases, the opposite is true -- the plural version returns results and the singular version throws a "not found" exception.
Anybody seen this and have any ideas on what may be causing it? It's become tedious to implement the obvious workarounds everywhere.
kfertitta Is it stable if you add some sleep before? FindElementByXPath and FindElementsByXPath have different behavior: FindElementByXPath try to search for an element during the ImplicitWait wait time, but FindElementsByXPath does not wait. Another option to use FluentWait https://www.selenium.dev/documentation/webdriver/waits/
@Shakevg Thank you for the reply. Unfortunately, that does not seem to be the issue, as I have, indeed, tried various waiting scenarios, including the DefaultWait
mechanism in WinAppDriver.
For example, the following does not return any results with FindElementsByPath
, where as the singular version does:
var wait = DefaultWait(....) { Timeout = TimeSpan.FromSeconds(10) };
var element = wait.Until(s => s.FindElementsByXPath(Locator).FirstOrDefault());
Is nobody else seeing such behavior? Happens a lot to us.
kfertitta I didn't face such issues, maybe it is a bug. You can use FindElementByXPath with DefaultWait for a specific case or try to change XPath as a workaround or try to search parent first, then child items with more simple XPath.
I also have same problem but with FindElementsByName and FindElementsByAccessibilityId. A lot of time. But still don't know how to resolve. Sometime it find, sometime it doesn't find and count = 0;
How about this #1284?
@Nativu5 , Yes indeed. A quick check reveals that turning off the "ms:experimental-webdriver" option makes FindElementsByXPath
work again. Thanks for that.
I guess the question is: what breaks/changes by turning this options off?