Appium Tutorial for Testing Android and iOS Mobile Apps

How to Install and Setup Appium on Windows with First Program to Get a Kick Start on Appium:

Appium is an open source and cross-platform tool that helps automate Mobile Apps testing – both Android and iOS Apps. Appium supports Native, Mobile and Hybrid Apps.

There are three types of Mobile Apps:

  • Native: Native apps built using the iOS, Android, or Windows SDKs. They are platform specific. They are built to work on a platform and/or device.
  • Hybrid: Hybrid apps are web applications developed using HTML, CSS, and wrapper of a native application on top of UIWebView for iOS and “webview” for Android Apps.
  • Mobile web apps: Mobile web apps are the apps ones accessed using mobile browsers.

Appium tutorial for beginners

Why is Appium a popular tool for automating Mobile Apps?

Appium is a “cross-platform tool” i.e. it allows you to write tests on multiple platforms (iOS, Android, Windows), using the same APIs. It is the most widely used tool for regression testing Mobile Apps on mobile phones and tablets.

Setting up the Appium Tool on Windows

Prerequisites: This is a short list of software and hardware required for automating a mobile App testing using Appium:

  • Your PC should have JDK, Appium Server, Eclipse, Android SDK installed
  • Apk: Mobile Application to be automated in our Case ContactManager.apk
  • Testing Device: In this case Moto G
  • Jars: Java-client jars and Selenium Jars.
  • USB driver for Testing Device: In this case Moto G

Step #1: Install the Java Development Kit (JDK)

Step #2: Set up Java Environment Variable Path

Step #3: Download and install Android SDK here  and update the APIs

To update API, Open Eclipse -> Click on Window in the Eclipse Menu and -> Select Android SDK manager

Update the APIs as shown in the below Screenshot:

Android SDK manager

Step #4: Now we need to install Appium for Windows. Go here and download Appium for Windows.

Step #5: Install Node JS from here: Node JS download 

Step #6: Set the ANDROID_HOME path as well as JAVA_HOME path

Specify the path for tools and platform-tool present in Android SDK path.

Android SDK path

These folders would be present in adt-bundle-windows-x86_64-20140702\sdk

Now we need to update the Environment variable (Refer below Screenshot)

(Note: Click on any image for enlarged view)

Update the Environment variable

Update path with tools and platform-tools (folder present in Android SDK).

The entry in Path will look as below:

C:\Program Files\nodejs\;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

Step #7:  Access adb

Press Win+R keys combination
Type CMD. Now in CMD type ‘adb’. adb will be accessible

Preparing Mobile Device for Automation with Appium

Connect your Mobile Testing device via USB to PC. Enable Developer Mode on Mobile Phone before automating the app.

Steps to Enable Developer Mode/Options on Android Phone or Tablet:

1) Open Settings, Tap on ‘About’ Option, Tap on ‘Software Information’, Tap On ‘More’.

2) Tap on “Build number” 7 times to enable Developer options.

3) Go back to Settings and make sure that “Developer options” is there.

4) Tap on Developer options and turn on USB Debugging option from the menu on the next screen.

Enable Developer Mode

For more help follow this link.

5) Download and install USB Drivers for the Mobile Testing device on PC.

6) In adb terminal type ‘adb devices’
C:\Users\NEERAJ>adb devices
List of devices attached
TA93305G0L      device

adb devices

This will display the list of devices connected to the system.We will be using App Contact Manager.apk as a sample App to automate. Download and install Contact Manager.apk on the device.

Starting  Automating Android App using Appium

Now run the appium.exe on PC.

Run Appium

Appium needs to be running and pass the following parameters and Device Name in Android Settings.

Note: Don’t change port number or anything in general setting icon. When Appium Server starts, the Server address, as well as Port address, will set by default. Port address will be 4723 by default

In Android Setting, the user needs to set APK path where the APK is located, Check app path, package and launch Activity.

  • Connect your android phone to PC and turn on USB debugging mode.
  • Open Command prompt.
  • Type command adb logcat.
  • Open app on your android phone. Immediately press CTRL + C in command prompt

press CTRL + C is package name and is activity name of Contact Manager app.

Contact Manager app

In above screenshot, we have populated all the needed information in Appium i.e package, launch activity, Mobile Device Name.

How to Locate Element using UIAutomatorViewer?

1) To automate the App firstly we will need to find the elements of the app that we will need to interact
for that, we will use UIAutomatorViewer

2) Connect the device in which App is installed to PC

3) Go to Terminal.

Type ‘adb devices‘

C:\Users\NEERAJ>adb devices
List of devices attached
TA93305G0L      device

This will show the list of devices connected to your PC.

4) Open the App which you want to automate in Mobile Device.

5) Open UIAutomatorViewer and go to the following path



6) So making sure your App is launched and UIAutomaterViewer is launched click on Device screenshot.

7) This option will take the screenshot of the App with all the detailed information of all the elements visible on the App.

App with all the detailed information

Click on Add contact Button for our Test Scenario

Add contact Button

From above screenshot, we can use locator“Add Contact”)

use locator By name

From above screenshot we can take By.className(“android.widget.EditText”)) as our locator for Contact Name

locator for Contact Name“Save”) can be used as our locator for Save Button

First program For automating an App on Appium

Run the below Script, Contact Manager application will be launched on the real device and all the logs will be displayed in the Appium console showing you the all the actions getting invoked by the above script.;;


public class appium {

 WebDriver driver;

 public void setUp() throws Exception {

//location of the app
 File app = new File("C:\\Users\\NEERAJ\\Downloads", "ContactManager.apk");
 //To create an object of Desired Capabilities
 DesiredCapabilities capability = new DesiredCapabilities();
//OS Name
 capability.setCapability(CapabilityType.BROWSER_NAME, "");
//Mobile OS version. In My case its running on Android 4.2
 capability.setCapability(CapabilityType.VERSION, "4.2");
 capability.setCapability("app", app.getAbsolutePath());
//To Setup the device name
 capability.setCapability("deviceName","Moto G");
//set the package name of the app
 capability.setCapability("app-package", "");
 //set the Launcher activity name of the app
 capability.setCapability("app-activity", ".ContactManager");
//driver object with new Url and Capabilities
 driver = new RemoteWebDriver(new URL(""), capability);

public void testApp() throws MalformedURLException{

System.out.println("App launched");
 // locate Add Contact button and click it
WebElementaddContactButton = driver.findElement("Add Contact"));;
 //locate input fields and type name and email for a new contact and save it
 List<WebElement>textFields = driver.findElements(By.className("android.widget.EditText"));
textFields.get(0).sendKeys("Neeraj Test");
 //insert assertions here


With Emerging Trend and more demand for Mobile Apps, all major companies are migrating to get their business on mobile apps. Thus to release the quality Mobile apps, automation Testing of Mobile Apps is the latest trend in the industry.

Appium, because of its simplicity and ease of use, is one of the leaders and most widely used tool all over the globe for performing Automation testing of Mobile Apps i.e. for iOS or Android.

About the author: This post is written by STH team member Neeraj. He is a passionate Software tester currently working as a Senior Software Development Engineer in Test and enjoys testing Web and mobile applications.

In our next article, we will discuss more on Mobile Automation Using Appium Studio Tool..

Recommended Reading

17 thoughts on “Appium Tutorial for Testing Android and iOS Mobile Apps”

  1. Hi…Do u have only this post available from Appium space?

    If a person from manual testing background, want to enhance his career in automation space, Is this the right place to enhance him in an automation space?

  2. Nice insights describing the learning about the Appium for the beginners. One more tool I would like to suggest for Mobile app testing through automation is TestingWhiz. This is a code-less test automation tool for web, database, cloud, mobile apps, etc.

  3. you have done gud work for sharing this appium tutorial for beginners..It is exactly what i was looking for.
    Thank You . keep going .

  4. hi,
    when we automate the mobile app,we need app source code? where we get the source code?how to use this code while automating the mobile app.plz give the info….

    thanks for sharing appium details….

    • hi, you don’t need to use the app source code for automation purpose as you have the inspector to identify each and every element.

      Thanks !

  5. Please tell me how to automate an iOS App. using Appium.
    Because i’m unable to find the objects elements to create script in iOS environment.
    Is there any tool for that like “UI Automator Viewer” for Android.


    • Hi Kuljeet,
      Here is the code for scrolling …

      public static void Scroll(int ScrollAmount)
      double scrollCounter = ScrollAmount / 100;

      if (AppiumDriver.executionOS == “iOS”)
      IJavaScriptExecutor js = (IJavaScriptExecutor)AppiumDriver.Instance;
      js.ExecuteScript(“window.scrollBy(0,” + ScrollAmount + “)”);
      else //Android
      AppiumDriver.Instance.Context = “NATIVE_APP”;
      System.Drawing.Size dimensions = AppiumDriver.Instance.Manage().Window.Size;

      Double screenHeightStart = dimensions.Height * 0.5;
      Double screenHeightEnd = dimensions.Height * 0.2;
      int scrollStart = Convert.ToInt32(screenHeightStart);
      int scrollEnd = Convert.ToInt32(screenHeightEnd);

      for (int i = 0; i < Convert.ToInt32(scrollCounter); i++) { AppiumDriver.Instance.Swipe(0, scrollStart, 0, scrollEnd, 2000); // break; } //driver.findElement("YourText")).click(); } }

  6. Not getting the Andriod SDK file on the link mentioned under #3) of “Setting up the Appium Tool on Windows”.

    Rather getting Andriod Studio link.

    Please help as I am stuck here.

  7. We have to automate native app for ios,android and we have web application too.How we can manage automating all, is it possible to do this with using single tool or we have to automate everything separately?

  8. when i am trying to use text attribute with name locator it throws exception that Locator Strategy ‘name’ is not supported for this session.

  9. How to automate mobile application if another finger scanner is attached to mobile device?
    take the scenario of mobile enrollment application where scanner is attached to mobile device.


Leave a Comment