WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

FindElementsByXPath (plural) vs FindElementByXPath (singular)

Open kfertitta opened this issue 3 years ago • 5 comments

I'm finding a number of scenarios where FindElementsByXPath returns no results where the identical locator used in the singular form of the method (FindElementByXPath) does return the expected element.

Any idea why this might be the case?

kfertitta avatar Nov 01 '22 13:11 kfertitta

FindElement uses the implicit timeout awaiting the element to be keyboard focusable. FindElement will fail if the element is not found. FindElements has no guarantee on the elements existence before completing and returning any elements existing at that moment. (Or in your case not existing yet.)

liljohnak avatar Nov 01 '22 14:11 liljohnak

@liljohnak , Thanks for the reply. Indeed, I'm aware of the usage of the implicit timeout for FindElement and have verified that the elements exist before either FindElements or FindElement executes. So, it does seem quite strange.

kfertitta avatar Nov 01 '22 14:11 kfertitta

Another strange behavior is FindElementsByClassName includs the parent element in the search

liljohnak avatar Nov 01 '22 15:11 liljohnak

Another strange behavior is FindElementsByClassName includs the parent element in the search

Yep. I see that consistently too. It's one of the reasons I try to use XPath, though that leads me to other strange behaviors. Would be so powerful to use if MS would get their act together on supporting this. But, so much time is spent working around these quirks in the implementation.

kfertitta avatar Nov 01 '22 16:11 kfertitta

It seems that ms:experimental-webdriver: true option breaks FindElementsByXPath. I set the option to false and FindElementsByXPath works.

See #1284

Nativu5 avatar Jul 04 '23 09:07 Nativu5