microsoft / WinAppDriver

Windows Application Driver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does WinAppDriver supports XPATH AXES with MobileElement::findElement(By)?

VladislavShcherba opened this issue · comments

I have encountered a problem that MobileElement's method findElement(By) does not work when using with XPATH AXES.
For example,
rootElement.findElement("./following-sibling::*")
always throws NoSuchElementException, although I am sure that the element exists.

I have also checked AppiumDriver<MobileElement> version of that method like this:
driver.findElement(byXPath("//*[@RuntimeId='<root-element-id-here>']/following-sibling::*"))
which results in the element I have expected.

I am using Java language binding. I checked the issue for the application we are automating on our project, and also for standard Windows 10 calculator.

Could you please suggest me based on your experience, can it be specifically problem of mine applications under test? Or maybe the issue is wider and exists for Java language binding. Or it exists for all languages, so let's say it is WinAppDriver server part problem? Thanks!

The answear is simple. Second search have access to entire dom so it finds element, first search have only access to current element and its child elements so it doesn't see siblings at all.

@HowTurnRight Thanks for your speedy reply! Do you mean I will have the same behavior using ChromeDriver and Selenium for example? If so, then I have to close the issue...

I dont know about other driver implementations but this one seems to be logical and correct behavior.

@HowTurnRight I have checked how Selenium and ChromeDriver works. It does find siblings when using WebElement's findElement(By) method with XPATH AXES.

I think this behavior should be considered as a defect.

I'm questioning whether this is well know behavior of WinAppDriver, or maybe I have encountered into some specifics, which maybe can be fixed somehow.

Of course it is possible to not use MobileElement::findElement(By) with XPATH AXES across automation framework. I just want to make sure that I'm doing everything correctly.

@anunay1 Hello! Would it be possible for you to confirm if I'm on the right track?

@VladislavShcherba
This implementations are not 1:1 but winappdriver is more logical. If you search in your root element why do you expect results outside of it? Its the same logic as a "//" xpaths, in chrome driver it will always search entire dom and in winappdriver only starting from your root element.