Automated Testing In Android Studio With Appium

1 min read

Dear Friends

My team member was actually having a hard time in figuring out how to execute Appium Test case in Android Studio. As a team leader and his mentor I have moral responsibility to lead from the front and I decided to give it a shot. Now when I was successful in my experiement , I thought to share this knowledge via Blog. After RELSELL LABS ( Relsell Global) is all about that.


1. Download appium tool for your relevant operation System.
2. Remember Appium tool requires Java 8 to work properly , nowadays.
3. Set few Environment Variables like JAVA_HOME, ANDROID_HOME and install appium tool. I have tested and done my experiment in Mac OS . setting environment vars for other OSs might differ a bit.

After that try to run appium tool application.

There are lot of good tutorials on Internet to do the above.

After you started your appium tool now its a time to connect tool to real device.
[ Remember you need to do some boilerplate configuration].

After your tool gets connected to real device now its a time to execute your first test case. But before that we first need to write our first test case.

Create a Java Class in test folder inside src folder for your android application, in android studio. If test folder is already present there’s no need to recreate. directly create java class.

package com.relsellglobal.appiumdemo;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;


import io.appium.java_client.remote.MobileCapabilityType;

public class FirstTestCase {

    WebDriver driver;
    public void testCaseSetup()throws  Exception

        DesiredCapabilities cap=new DesiredCapabilities();
        // put relevant device id below ... first check in CMD
        cap.setCapability(MobileCapabilityType.DEVICE_NAME, "23e6841c");
        cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "5000");
        cap.setCapability(MobileCapabilityType.APP, "//Users//anilkukreti//Documents//BitBucketProjects//freecall//app//build//outputs//apk//app-debug.apk");

        // Ensure you have started appium server before executing your test case

        driver = new RemoteWebDriver(new URL(""),cap);


    public void testcase1()throws  Exception
        WebElement textView = driver.findElement(new By.ById("logintextview"));
        // click on button and start second Activity

        String resultText = textView.getText().toString();

        Assert.assertEquals(resultText,"Login to Freecall");


    public void testCheckLoginButtonText()throws  Exception
        WebElement button = driver.findElement(new By.ById("login_button"));
        // click on button and start second Activity

        String resultButtonText = button.getText();



    public void testCaseTearDown()


Now you have a java class.

Execute your testcases file and see the results of testcases in Android Studio window .