Mobile Custom XPATH locator

Hi I have a question does xpath in mobile & web works the same way? In Web i can use xpath like following-sibling but does it work the same way for mobile ? Cause i tried it seems to not be working ??

This is the custom xpath that i made //*[@class = ‘android.widget.TextView’ and (@text = ‘User ID’ or . = ‘User ID’)]/following-sibling::android.widget.ViewGroup/descendant::android.widget.EditText


Was it the wrong syntax??

1 Like

Hi there, :wave:

Thank you very much for your topic! It may take a little while before Katalon team member or others forum members respond to you.

In the meantime, you can double-check your post to see if you can add any extra information i.e. error logs, HTML codes, screenshots, etc. Check out this posting guide to help us help you better!

Thanks! :sunglasses:
Katalon Community team

I might try some variation on your pathway, since you have several ‘siblings’. So, how about?

//*[@class = 'android.widget.TextView' and (@text = 'User ID' or . = 'User ID')]/following-sibling::android.widget.ViewGroup[1]/android.widget.EditText

or maybe even

//*[@text = 'User ID' or . = 'User ID']/following-sibling::android.widget.ViewGroup[1]/android.widget.EditText

I haven’t been able to get the follow-sibling to work on mobile but I believe you can use this custom xpath to do the same thing:

//*[@class = ‘android.widget.TextView’ and (@text = ‘User ID’ or . = ‘User ID’)]/..//*[@class = 'android.widget.EditText']

The bit in bold below - I can’t see that anywhere in the hierarchy, so syntax might be correct but one of your nodes is not:

“This is the custom xpath that i made //*[@class = ‘android.widget.TextView’ and (@text = ‘User ID’ or . = ‘User ID’)]/following-sibling::android.widget.ViewGroup/descendant::android.widget.EditText”