Automate Android App in Appium with Data-Driven Framework

Reading Time: 4 minutes

Hi friends,

Welcome to our appium blog series,

In the last blog, we know about the desired capability which helps a lot in an appium to test whatever android or iOS to know more about the problems related to appium and also for better understanding of Desired Capabilities which are essential for mobile testing so please go through our previous blogs from here but this time we focused on something advanced in appium related to android only because as we know for testing iOS we required a real iOS device so we now choose the android machine but in future, we also try for iOS device.

Initially, In this short blog, we learn about “how we automate android app with DDT“, so as we discussed earlier, Appium is an automation testing tool used for mobile testing as well as it helps to automate tests with the help of a selenium web driver. It also required a connection between mobile and Appium server that things which help to make a proper connection between are known as “Desire Capabilities.” you also get some advanced knowledge how appium work with DDT so first discussed what is DDT framework.

Data-Driven framework(DDT)

Basically, Data-Driven Testing is a software testing method in which test data is stored in table or spreadsheet format. It allows testers to input a single test script that can execute tests for all test data from a table and expect the test output in the same table. so set up a data source and add an excel(.xlsx) file with input into it then call into the main function like this,

ReadData excel = new ReadData("TestDataFile/datadriven.xlsx");

Set up environment with Appium and IntelliJ

As we discussed earlier we need a proper setting for testing in my last blog, you can get references for more here

For proper environment set-up, follow the below steps:-

  1. Install appium server (GUI or command line).
  2. Install nodeJs.
  3. Set android home and java home path
  4. Install android studio.
  5. Download android version and android emulator from android studio.
  6. Install IDE (IntelliJ)
  7. Download and install apk info.apk in emulator or real device.
  8. Download UI automator viewer.

Setup Your Project

Launch IntelliJ, select “File” > “New” > “Maven Project” and follow through the dialogs with the default settings. Next, let’s add the appium and selenium dependency. Dual click on the pom.xml file and edit the <dependencies>…</dependencies> block to look like this:


Write A Basic Setup Script

In the IntelliJ file explorer, extend “src/main/java” and extend the package.

public class demo1 {
    public static void main(String[] args) throws MalformedURLException {
        DesiredCapabilities  desiredCapabilities = new DesiredCapabilities();
        desiredCapabilities.setCapability("platformName", "Android");
        desiredCapabilities.setCapability("appium:platformVersion", "11.0");
        desiredCapabilities.setCapability("appium:automationName", "appium");
        desiredCapabilities.setCapability("appium:noRest", true);
        desiredCapabilities.setCapability("appium:udid", "emulator-5554");

As we discuss above we automate an android application so every app has a different appActivity and appPackage, we know both with the help of the “app info” so First installed android application installed in our emulator.

        cap.setCapability("appActivity"," - Phone");

How to capture main desired capability

After adding this Desire Capability appium can be lunch the special app in an emulator or real device but before that, we need to add localhost port of appium and also add appium-selenium Android driver into code.

         //localhost where appium server run
        URL url= new URL("");
        AndroidDriver<WebElement> driver=new AndroidDriver<WebElement>(url,cap);
        //after lunching the application it wait so we add below function.

How to access the button and how we capture it

Half the steps are done towards the automaton and also now accessibility ID is required to locate the element in the emulator or real Android device.

I choose a phone dialer as an android application for our testing. so we need to access and also capture the buttons in our application, so let’s add the resource ID or sometimes accessibility ID of a particular button in the .xlsx file as an external data source. to get resource Id or some other different ID of a particular button we follow certain steps given in our Gif file with the help of one of the following.

  • Appium Inspector
  • UI Automator viewer
          MobileElement el8 = (MobileElement) driver.findElementByAccessibilityId(excel.getData(0,0,1));;
        MobileElement el9 = (MobileElement) driver.findElementByAccessibilityId(excel.getData(0,1,0));;
        MobileElement el10 = (MobileElement) driver.findElementByAccessibilityId(excel.getData(0,1,1));;
        MobileElement el11 = (MobileElement) driver.findElementByAccessibilityId(excel.getData(0,2,0));;
        MobileElement el12 = (MobileElement) driver.findElementByAccessibilityId(excel.getData(0,2,1));;
         System.out.println("Application started........");


Before running the above program we need the following things in running state.

  • Appium server
  • emulator or real andriod device

That’s all for this blog, I Hope so learned about appium and how we automate an android device, and in the next blog, we will learn more about appium so stay tuned.

To know more about android automation and get the proper code of data-driven testing using appium please go through our tech-hub link:

Thank you!!  


Written by 

I am a self-motivated self-starter with strong analytical, problem-solving, communication, Always interested to learn new technology, and interpersonal abilities. I am currently employed as a Quality Assurance Software Consultant. I am well-versed in creating automation frameworks and am familiar with key QA ideas. I have previous expertise with automation technologies such as,,, Selenium (Java), Appium, Grafana-k6, and core Java Development Tools. Maven, Version Control GIT (GitLab Project Management Tool). QA Tools for Performance Testing Automation as well as performing QA at Knoldus Leaderboard It is a Web-based program that keeps track of Knolders' contributions (people working in the organization). It can provide points to contributors based on their contributions.