0

Currently I am using Appium, Selenium, Java, TestNG for native app. I am doing automation for iOS and Android and both functionality is same but yes element identifier is different in iOS and android. None of element have same name. Let’s say for login button element identifier is in following way

For Android

@AndroidFindBy(id = "com.abc.bot:id/home_screen_sign_in_btn")
    private MobileElement signinbtn;

For iOS

@FindBy(xpath="//XCUIElementTypeButton[@name='Log In']")
    private WebElement logInButton;

Apart from that we are using CircleCI and for iOS and Android have different pipeline and different branch too. My question is, should I keep iOS and Android in same repo or different branch. Can someone explain pros and cons please?

Hari
  • 75
  • 2
  • 10
  • 1
    Maybe the answer here helps combining your locators: https://stackoverflow.com/questions/57438847/appium-design-page-object-to-reuse-same-function-with-ios-and-android – AndiCover Aug 14 '19 at 09:10
  • @AndiCover That for reply. That helps. – Hari Aug 14 '19 at 17:19

2 Answers2

2

I actually just set all this up for the company that I am currently at. Im assuming that if you are using appium, selenium, java, testNG that you are using the appium studio plugin for eclipse or intelliJ and if you are not you should be it wil make your life much easier but anyways. I kept everything in one repo and here is the reason

If you have everything in one repo, this means you have one singular project that you have to work with. Not to mention you can create xml files that have all your tests from both platforms and can run them all together.

You dont want to be switching repos/projects every time you need to do something because that would be tedious and time consuming not to mention error prone.

what I did for my framework is I added Android page folders and iOS page folders that way I could keep them separate, same with the tests. This way I can do all my work in the same spot without getting things confused. There really is no downfall to keeping both platforms in 1 repo if you have it set up right.

Separate folders for dumps and tests, 3 xml files one test suite that contains all the iOS tests, one that contains all the Android tests and one test suite that contains both of those tests suites so you can run all your tests on both platforms

I would say in general 1 singular repo has all the pros and 2 repos has all the cons from just being to spread out and unconnected.

Not to mention with one repo everything is coming from the same place so when you start the CI is going to be much easier to get going and make changes to in the future and when you run jobs for either platform your only condition will be what xml files to use.

If you want me to go into further detail or just have questions let me know and ill edit my answer and answer whatever you want me to

PS everything I have done is up and running 100% and is really smooth

Brent
  • 740
  • 1
  • 5
  • 11
1

You could stick to single locator strategy, for instance XPath Selector and use XPath Union operator to combine both locators into one like:

//XCUIElementTypeButton[@name='Log In'] | //*[@resource-id='com.abc.bot:id/home_screen_sign_in_btn']

A better approach would be putting your locators into a .properties file like:

android.signin.button=//*[@resource-id='com.abc.bot:id/home_screen_sign_in_btn']
ios.signin.button=//XCUIElementTypeButton[@name='Log In']

And then query the desired element by combining platformName Desired Capability with the locator from the .properties file

Properties uiprops = new Properties();
uiprops.load(new FileInputStream(new File("ui.properties")));
String locator = uiprops.get(appiumDriver.get().getCapabilities().getCapability("platformName") + ".signin.button").toString();
Dmitri T
  • 159,985
  • 5
  • 83
  • 133