Appium setup 1 2

How to do Appium Setup with Testing in Android Studio?


This article is targeted to the uses who wish to configure mobile automation testing with android studio. We already have an article on Appium with eclipse. Now this time we have come with the more technical aspect of the configuration of Appium with android studio. Users can understand how testNG annotation can be used in test scripts if you’re interested in Appium, how it works and how it is automated to the mobile app then this topic just state the basics of these concepts. I assume you might have at least basic knowledge of Appium.


Appium goals to automate any mobile application from any languages like Ruby, Python, Java, JavaScript, PHP, C# and any test framework, with full access to back-end APIs and DBs from the test code. You can write your tests with your favorite developer tools using all the programming languages and probably with the Selenium Web Driver API and language-specific client libraries. It is freely distributed open source mobile application and supports Native, Hybrid and Web application testing and provide automation test support to physical devices as well as emulator or simulator both.

It provides the cross-platform and writes tests in multiple platforms like iOS, Android, Windows using with the same APIs. This provides code reusability between iOS, Android and Windows test suites.

How does it work?

Appium enables Android and iOS automation using Selenium WebDriver .The same WebDriver binding can be used across web and mobile and it supports software test automation on Emulator or Simulator and Physical devices too.

Prerequisite to use Appium:

This blog will let you configure the Appium over android studio using a testNG framework. Once we go through the blog things will be defined more precisely but first, we should configure Appium & android at our local machine.

1. Android studio can be downloaded from

2. Appium sever can be downloaded from

3. The selenium jar file can be downloaded from

4. Set Java Home & Android Home from environment variable if it is not configured.

Appium Test Case for Native Android App (Calculator):

  1. a. Create your first test script
  2. b. Launch Appium Node server
  3. c. Execute your first test

To start with Appium we should understand with pre-requisites required for setup. Create a project in Android Studio and follow the basic tricks one after another. We need to add the jar files to our Android project. You could find the folder named as libs inside the folder named as the app. We need to paste all jar file except selenium standalone server. Let me tell you the jars you need to add apart from selenium jar files. These jar files are easily available over the internet.

For TestNG –  testng-6.14.2.jar

Just follow the three-step process defined in below image to add external library files to your project in android studio.

We need to perform a bit changes in build.gradle file. Junit is configured as default by android studio. We need to configure testing by committing a few changes in build.gradle file.

We need to comment Junit dependencies so that your program does not run the default configuration of Junit, you could easily observe the decencies required in the form of jar files through my current build.gradle .

You need to edit the run configuration so that your test runs with testNG

You need to add new configuration is of testNG type and class should be mention as you runnable class and other detail should be configured the details. Please configure the details and become ready to write your test script.

I am having two Java class files under test folder inside src. I am storing locators inside and creating test script in Creating different classes for different utilities is the best practice. We can easily find out the locators of web elements in the browser through the developer console. Finding mobile elements is a bit tricky but the android studio has inbuilt tool.

Let me give you a quick brief so that you can find locators. You need to open
uiautomaterviewer.bat , this tool is available inside sdk folder of android. We don’t need to perform separate installation. The general location of sdk is mentioned below; however, it may vary as of your given location at time of installation of android studio.

Default location – C:\Users\Username\AppData\Local\Android\sdk\tools\bin

Your device should be recognized by adb and it should be connected in active mode then only this viewer will capture your current screen content and transform them in xml.

Now you are all set to write your first test script. Create a small test Program for calculator application on your device using Appium. I have placed all the required locator of my test script in this class. I am creating my test script on a calculator app. The code has been mentioned below.

I have placed my test script inside, it has different testNG annotations, code logics & Desired Capabilities that are required for communication with a connected device. My script is written for the actual device connected with a machine, but you can also create it for emulators. We have a choice either to run the script on an emulator or on the actual device.

To run this program, we need to start Appium server & configure the server’s host and port as passed for RemoteWebDriver in the above program.

Once Appium server is done, you can run your configuration. Make sure the device is connected and unlocked. appPackage Name Launch appActivity name mentioned has a match with a connected device. All rest desired capabilities configured correctly.

Your first Appium test script on android studio with testNG will run perfectly. Happy testing

About Author:
Author Aaqib Ansari is a Sr.QA Engineer currently working with QSS Technosoft. He is a technology writer in .Net, Selenium, SQL and frameworks like TestNG. He has completed his Master’s degree in Computer Science

About QSS:
QSS has a proven track executing enterprise level web and mobile applications for itsesteemed customers. The company has a core Testing competency in place for testingEnterprise level applications. The Testing Center of Excellence (TCoE) has experienced anddedicated team of QA engineers who can efficiently perform both manual and automatedtesting assignmentsToKnow More...

Tags: , ,

Hire certified


  • Avg. 6+ Years of Experience.
  • Dedicated Resource on Demand.
  • NDA Protected Terms.
  • Start/Interview within 24 Hours.
  • Flexible Engagement Models.
  • Best code practices.
Start Now!


6 Most Important Factors for a Successful Mobile App!

Every precaution that you take in the development process will help you to be effective in building products that will help you grow and reach your goals. Consider these 6 factors before heading for mobile app development.

Subscribe to our newsletter and stay updated