Create an Appium Project by Integrating Appium-Eclipse-Maven-TestNG

This blog will explain the steps to follow for creating a simple Appium project.

Prerequisite: following software’s should be installed:

  • Appium GUI App
  • Java
  • Eclipse
  • Maven
  • eclipse-maven-plugin
  • eclipse-TestNG-plugin
  • Genymotion Android Emulator

Step 1) Lets create a new project in eclipse by following steps:

Click on new –> Other –> Maven –> Maven Project — > Next


Step 2) Now click on Simple project and keep the default workspace location.


Step 3) Provide details as Artifact id, Group id, name and description. and click on Finish.Screen Shot 2016-02-24 at 5.32.22 pm

Step 4) This should create a basic maven project. Now we need to add Appium and TestNG Dependencies in pom.xml.

<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">



		<!-- Appium -->

		<!-- testng -->



Step 6) We will create a simple project structure, to keep files at logical places. We need to create few packages, and please see below screenshot for better understanding.

Screen Shot 2016-02-25 at 4.14.00 pm.png
Step 7) We will add the andrroid apk that we will use for the demo, to apps folder. ApiDemos-debug.apk is available in assets folder in Appium source code.

Step 8) Now we will create a new class in appium package, AppiumDriverBase. Add following code to this class:

package appium;



import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;

public class AppiumDriverBase {

    protected AndroidDriver driver;
    protected WebDriverWait wait;

    //before Test Annotation makes a java function to run every time before a TestNG test case
    protected void createAppiumDriver() throws MalformedURLException, InterruptedException {

	//relative path to apk file
	final File classpathRoot = new File(System.getProperty("user.dir"));
	final File appDir = new File(classpathRoot, "src/test/resources/apps/");
	final File app = new File(appDir, "ApiDemos-debug.apk");

	//setting up desired capability
	DesiredCapabilities caps = new DesiredCapabilities();
	caps.setCapability("browserName", "");
	caps.setCapability("platform", "ANDROID");
	caps.setCapability("platformVersion", "5.0");
	caps.setCapability("deviceName", "ANDROID");
	caps.setCapability("app", app.getAbsolutePath());

	//initializing driver object
	driver = new AndroidDriver(new URL(""), caps);

	//initializing explicit wait object
	wait = new WebDriverWait(driver, 10);

    //After Test Annotation makes a java function to run every time after a TestNG test case
    public void afterTest(){

	//quit the driver



Step 9) now we need to add a test case. Create one more class in Appium package and add class ‘SampleTestCase’. Add following code to this class:

package appium;

import io.appium.java_client.MobileBy;

import org.openqa.selenium.By;
import org.testng.annotations.Test;

public class SampleTestCase extends AppiumDriverBase{

    //Test Annotation changes any java function to TestNG test case
    public void sampeTest(){

	//click on Accessibility link

	//click on 'Accessibility Node Querying' link
	wait.until(ExpectedConditions.presenceOfElementLocated(MobileBy.AccessibilityId("Accessibility Node Querying")));
	driver.findElement(MobileBy.AccessibilityId("Accessibility Node Querying")).click();




PS: for simplicity purpose i have kept first test case as very simple. you can modify it as per your convenience.

Step 10) Now we need to run the sample test case. For that we need to get Appium Server and Android Emulator app and running.

– Appium Server running via GUI on mac looks like this:
Screen Shot 2016-02-25 at 5.20.00 pm

Step 11) Once Appium Server and Android emulator are up and running, we need to execute the test case using TestNG plugin.

Screen Shot 2016-02-25 at 5.32.20 pm

This steps will help you start with Appium project in Java.


2 thoughts on “Create an Appium Project by Integrating Appium-Eclipse-Maven-TestNG

  1. Hi,

    Thanks for the informative post. I had one question here. I am able to successfully run the script in windows, but everytime i have to run appium server and emulator before running the script. Is it possible to integrate appium server and emulator in the maven or in Jenkins so that the manual intervention can be avoided?.

    Thanks and Regards,
    Lalith Kumar Sharma


    • Hi Lalit

      You can start Appium Server and Emulator once before starting the first test, after that, all test cases will use the same server and same Emulator.

      Also, if you are preparing the test cases, then keep the Appium server and Emulator running in the background, No need to start it again and again.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s