Ionic app automation with appium - release choice instead of xpath

Typically when we work with selenium automation of a website, we go with say an element id, which is intuitive, human readable and via a process can be locked down to be shared between developers and automation engineers.

Our current assignment is automation of an Android app (hybrid app using Ionic) with Appium (running on web driver context, not native context).

Things are different here since Ionic generates the HTML on its own from the code and disregards the element ids given by the developers.

So we are left with the only option of using xpath which looks like:

//UIAApplication[1]/UIAWindow[1]/UIAScrollView[2]/UIAWebView[1]/UIAButton[1] or //html/body/div[5]/div/div/div[1]/div[1]/div[3]/div[1]/div[2]/div[3]/div[2]

(note not written by developers, generated by Ionic).

This makes us uncomfortable for 2 reasons:

Not intuitive like before since we did not write it
Do not have clarity what changes by developers will cause a change in the xpath and break the automation test cases (basically need a system to prevent automation scripts from regressing because of developer code changes).
This brings me to 2 questions:

Is there a better option possible for identifying UI elements in a hybrid app than this
If not, is their an explanation for the two concerns posted above.
Any help will be much appreciated


Just is not entirely true … Just ask the developer to add the ID in the field and you can search by ID.

The problem is that there are fields that the developer could not place the ID, then IONIC will put a dynamic ID. When this dynamic ID changes, it will surely break your automation code.

Changing to the context of WEBVIEW, it works with ID that the developer places and with the dynamics.

A solution for dynamic IDs. so they do not change.

For more information