Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
VladislavShcherba opened this issue Feb 19, 2024 · 6 comments

Comments

@VladislavShcherba
Copy link

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!

@HowTurnRight
Copy link

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.

@VladislavShcherba
Copy link
Author

@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...

@HowTurnRight
Copy link

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

@VladislavShcherba
Copy link
Author

@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.

@VladislavShcherba
Copy link
Author

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

@HowTurnRight
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants