Xpath are changing on Andriod and ios for a app devloped on appcelerator

we have app that is developed on appcelerator ( a tool used in development of mobile app by which no need to write separate code for iOS and Android app )

  • our objective is to write a single test script that would test on Android as well on iOS

currently the problem we are facing is either uiautomator/appium inspector not able to identify the id/content-desc attribute of any elements

so we don’t have any other option than xpath
But problem with xpath is on android and ios xpath will be diffrent for the same element

  • that means we would have to maintain two object repo’s for this
    (this would cost High maintenance)

  • is there any other tool/work around that could be done to show the all attributes of those elements ?
    or any other solution is appreciated

Thank you.

1 Like

you can use PageObject approach to combine page element e.g.

                @iOSFindBy(uiAutomator = ".elements()[0]")
        	@AndroidFindBy(className = "android.widget.TextView")
        	private List<WebElement> androidOriOsTextViews;

Thank you for your reply… this means we have to maintain seprate way to find elements in iOS and android but if we have element id’s visible then driver.findelement(by.id(“idname”)) would work in both platform … so good solution would be to have uiautomator/appium inspector to detect these attributes … is there alternate tool avialable ???

driver.findelement(by.id(“idname”)) - valid for Android only. iOS does not have ID but Accessibility ID.

example:

@iOSFindBy(accessibility = "homeButton") //iOS
@FindBy(id = "homeButton") //android
private WebElement homeButton;

public void tapHomeButton() { // OS independent code
        driver.tap(1, homeButton, 200);
    }
1 Like