Saturday, 16 May 2015

First Mobile Automation test using Appium

What is Appium?
Appium is a mobile automation testing tool used to test android and IOS applications.

Installation and Setting up of Environment for running Appium tests
Please follow below steps to set up the environment.

  1. Download and Install Java. Set up JAVA_HOME and JRE_HOME.
  2. Download and Install Android SDK. Set up ANDROID_HOME.
  3. Also configure system path variable to include Java and Android tools.
  4. Download and Extract Appium.
  5. Set up device (Virtual device or Android phone) on which tests have to be run. If you are using real Android phone for testing then please enable developer option by tapping on the version menu (found in settings->About device)  7 times. Once Developer option is made visible, you should enable usb debugging. Then you can attach your device to laptop using usb cable. For the first time, your device mac address will be registered in device manager, You also need to accept a message to acknowledge the registration on your phone.

First Program to test Calculator using Appium
You can run write your tests in any language like Java, C#.Net, PHP, Python etc. Below program uses C#.Net language.

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support;
using OpenQA.Selenium;
using System.Text.RegularExpressions;

namespace Appium
    public class UnitTest2
        public void TestMethod1()

        IWebDriver driver;
 DesiredCapabilities capabilities = new DesiredCapabilities();
 capabilities.SetCapability("BROWSER_Name", "Android");
 capabilities.SetCapability("VERSION", "4.4.4"); 
   capabilities.SetCapability("appPackage", "");
   driver = new RemoteWebDriver(new Uri(""), capabilities);

   //locate the Text on the calculator by using By.Name()

   IWebElement txt= driver.FindElement(By.ClassName("android.widget.EditText"));
   String p = txt.Text.ToString();
   String replacement = Regex.Replace(p, @"\t|\n|\r", "");
   Assert.AreEqual(replacement, "3+5=8", txt.Text);


Running First Program to test Calculator using Appium
Please follow below steps to run above test using Appium.

  1. Launch Appium Application by double clicking on Appium exe file.
  2. Start the server.
  3. Attach your device in debug mode.
  4. Run the program and see the magic!! Calculator application is launched on your device and sum of 3 and 5 is done.

Difference between Appium and Selendroid
Appium can be used to test android as well as iOS based application. Selendroid can be used to test only Android based applications. Selendroid can test application developed using API level 17 and below. But Appium can only test application developed  using API level 17 and above. We can record steps using inspector tool in Selendroid. We can use UI automater viewer tool in Android SDK to inspect the elements of application.

What do you think on this topic? Please express your opinion or ask any question through comment below. You can write to me at

No comments:

Post a Comment

Leave your valuable feedback. Your thoughts do matter to us.

Sponsored Links

Popular Posts