Is xpath changes between devices?

I wrote test code, It works perfectly on source device but when executing the code on another device it does not work properly.
Do have any idea about it?

@msmirzazadeh just stop using xpath is only solution. you have bunch of alternatives and all of them are faster and do not change from device to device.

  1. best is “id”
  2. when “id” absent from some given element you can try to use it’s descrition
  3. user CHAIN e.g. :slight_smile:
    @HowToUseLocators(androidAutomation = LocatorGroupStrategy.CHAIN)
    @AndroidFindBy(id = "someID")
    @AndroidFindBy(className = "android.widget.ImageButton")
    private List<AndroidElement> infoButton;
  1. use predicates (iOS) or UISelector (Android)

xpath doesn’t change between devices as longs as its the same app version and developer hasn’t changed any locators in the new build.

Are you testing your app in iOS or Android device? If Android can you share the OS version of source device and the other device on which cases are failing? If its 7 or more then include the below in your Desired Capabilities file.

automationName: 'uiautomator2'