Hi,
I am testing a Xamarin app for Android. It is a big change from Web apps.
There are no ID tags. Most of the elements do not have text attributes/labels.
My question is - do people really have success with xpath or is there something I should speak to a developer to improve support for automation? Can I simplify the mess below and make it a relative xpath?
A typical xpath looks like this:
//hierarchy/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]/android.view.ViewGroup[1]/android.view.ViewGroup[1]/android.view.ViewGroup[2]/android.view.ViewGroup[1]/android.widget.ScrollView[1]/android.view.ViewGroup[1]/android.view.ViewGroup[1]/android.view.ViewGroup[1]/android.widget.FrameLayout[1]/android.view.ViewGroup[1]/android.view.ViewGroup[4]
Thanks for any support, Dan
You may find the following article interesting.
You should interpret âExt JSâ --> âMobile Appâ and âSeleniumâ --> âAppiumâ. At one layer of abstraction up, the article applies to your case as well.
I suppose you should discuss with your developers to tune your AUT with E2E testing in mind.
1 Like
Hi - thanks, thatâs a useful read and I think my options are:
a) handcraft xpath for objects that lack unique identifier, since Object Spy/Recorder for Mobile only offers absolute xpath (and https://www.katalon.com/resources-center/blog/smart-xpath-generator/ does not appear to work for mobile tests)
b) ask Dev to add some identifiers
For option a), I note that we canât verify mobile xpath in Object Spy, like you can for web apps (for example, I try â//*[@text=âIncident No.â]/following::android.widget.EditTextâ). Tester must execute test to verify if this locator is correct. This seems like a useful feature request, unless Iâm missing something.
Regards, Dan