I'm starting a new Appium project to test a native mobile application on both Android and iOS, and need some guidance. So far I've found it's very confusing - there are so many options out there, and it seems to be a very fast moving target - what worked a mere 6 months ago can often not work today.

I'd like to know:

  • What driver should I use? On Android, should I just stick with AndroidDriver? Or should I use AppiumDriver<MobileElement>? Perhaps something else?
  • What should I use for the elements? WebElement? AndroidElement? MobileElement?

I don't mind maintaining two code bases (one for iOS and one for Android). At the moment, I'm just concentrating on Android.

  • Your question is a bit too broad, and limited to a small niche. You might have better luck is you ask about concrete obstacles you encountered. Try to find few relevant blogs/tutorials, follow them, and see what you can learn from the experience. No technology is a silver bullet, all have pro and cons (so I can see why you want to chose the "right" one). Also, feel free to post here as answer what you learned, "to help the next guy" (TM) Good luck! Jan 30, 2018 at 14:07

2 Answers 2


I totally relate to what you are going through. I felt the same way when I first started using Appium a while ago for iOS and Android automation. Just like other frameworks there are different ways to achieve what you want with appium. Let me try to answer your question based on my experience using Appium+Cucumber+Java for both iOS and Android Automation.

-If you are using the Page Object pattern,I would use

import io.appium.java_client.android.AndroidDriver;

import io.appium.java_client.ios.IOSDriver;

import org.openqa.selenium.WebElement;

Once you do this then you can use the iOS and Android drivers wherever you want. Also, using WebElement you can use all the normal appium commands. You mentioned "MobileElement"; which is a subclass of "WebElement"

In case you want to tap into Offline mode, Airplane mode features then you would need this package

import io.appium.java_client.android.Connection;

and then you may do something like this

((AndroidDriver) DRIVER).setConnection(Connection.AIRPLANE); //To switch to airplane mode

-If you are using Page Factory Pattern (An extension of Page Object pattern), I would use

import io.appium.java_client.pagefactory.AndroidFindAll;

import io.appium.java_client.pagefactory.AndroidFindBy;

import io.appium.java_client.pagefactory.AppiumFieldDecorator;

import io.appium.java_client.pagefactory.iOSFindBy;

import org.openqa.selenium.support.PageFactory;

import org.openqa.selenium.WebElement;

Once you do this you can start using annotations like

@AndroidFindBy(id = "android resource id")

@iOSFindBy(accessibility = "iOS accessibility id")

private WebElement commonVariableToRepresentBothIds;

Hopefully this helps :-)



I use AndroidDriver and correspondingly AndroidElement with the pagefactory's AndroidFindBy and it works great.

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.pagefactory.AndroidFindBy;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.