This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
1 / 10
Dec 2014

I am using Eclipse Junit write test cases for iOS. Test cases works fine in one version which I wrote for , but when test new version builds many xPath of the element will change so I have to change them manually. It will cost me a lot of time to change them, any better solution for this problem.

I am trying to use find element by name or Id but some elements only xPath and location can be traceable by Appium Inspector.

This blog http://blog.prototest.com/appium-xpath-locators-ios26 recommend me to use location, but I did do that, because by using find element by location, the test cases may not success in other devices with different screen resolution. please collect me if I am wrong.

  • created

    Dec '14
  • last reply

    May '18
  • 9

    replies

  • 1.8k

    views

  • 7

    users

  • 1

    link

7 months later

Even I am facing the same issue, not only that xpath changes for different runs of same test case on same app build :frowning:

Solution: don't use brittle index-based xpath. Instead use shorter xpath statements that utilize a unique attribute. For example, an iOS Cancel button may have a valid xpath of:

//UIAButton[@name="Cancel"]

It's unlikely the element type UIAButton is changing, nor is it likely the name/text of the button is changing. Thus that xpath will be robust and reliable. Assuming there's not multiple Cancel buttons on the same screen. :slightly_smiling: Then you need to come up with some other unique xpath such as including the parent element in the xpath such as:

//UIATableRow/UIAButton[@name="Cancel"]

Thanks Chris for Replying, Problem is Elements don't have Name, Label or Value Attributes defined for them.

1 year later

Name property is valid only for label div what if there is text field, drop down or readiobutton controls .Find element by id is also not works with ios if there is no name to the element.Please suggest approach to find elemnts like textfield dropdown and othere html controls those have not name property

Even i am facing the same issue....
Locators are changing from devices to devices (some devices displaying the locators values like resource-id, Text, content-desc....etc and some devices not...).
I am trying to automate hybrid app which uses Html5.

Thanks in advance,
Sekhar.

Though its not a solution, Ideally you should request developers to use unique IDs as much as possible, Automation should be team effort, not only QE.

Hi RamS,

Thanks for the reply,,,

Even Unique id specified not displaying when mobile device /os version changed.
Eg : Able to see the resource-id and other supported properties at 'UI Automator Viewer' and when i try to install the same app in other devices (Samsung/Moto)... those properties are not displaying(empty) hence my tests failing when switching devices . Mine is Hybrid application which uses Kendo UI-Html5 for views/pages.

Found the cause...

i am using two devices for running the tests ... one compatible with Html5 and another one Html (moto E). Properties gets changed because of the compatibility issue in Moto E for views

Thanks,
Sekhar.

1 year later

i also facing same issue for iPad’s application