App & Browser Testing Made Easy

Give your users a seamless experience by testing on 3000+ real devices and browsers. Don't compromise with emulators and simulators

Home Guide How to run Appium tests on Android devices?

How to run Appium tests on Android devices?

By Neha Vaidya, Community Contributor -

Table of Contents

Automation is quickly becoming a mandatory part of software testing. From web applications to mobile apps, all software can benefit from automation testing. The market is flooded with various tools for automation out of which Appium is frequently used for testing mobile applications.

This article will dive deep into how Appium can be used to run tests on an Android device so that testers can verify their apps for real-world functionality.

Appium is an open-source framework that allows us to conduct automation testing of mobile applications on different platforms like Android, iOS, and Windows.

It automates the testing for:

  • Native Mobile Applications that are written using iOS, Android or Windows SDKs
  • Mobile Web Applications that can be accessed using mobile phone browsers such as Safari, Chrome or the in-built native browser applications for android devices
  • Hybrid Mobile Applications that have a native wrapper around the web view
    Appium is a cross-platform testing framework that is flexible, enabling you to write the testing code against multiple platforms such as iOS, Windows, and Android using the same API. This means you can use the same code for iOS that you have written for Android, saving lots of time and effort.

For a detailed introduction, refer to this Appium Tutorial for Mobile Application Testing. Additionally, refer to this article for detailed instructions on Appium installation.

Run Appium Tests on Android Devices

Let’s start this with the installation process. Follow the steps below for installation.

Download the following components to run appium tests on Android:

The code below demonstrates how to write Appium test scripts. The example here uses Eclipse IDE to run Appium tests on Android devices.

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 org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class AppiumExample{
WebDriver driver;
WebDriverWait wait;
String AppURL = "";
public void setup() throws MalformedURLException {
// Create an object for Desired Capabilities
DesiredCapabilities capabilities = new DesiredCapabilities();
// Name of mobile web browser to automate. capabilities.setCapability("browsername", "chrome");
//device name
capabilities.setCapability("GalaxyS4", "WKZLMJLB7L8TR8SW");
// Which mobile OS platform to use - iOS, Android, or FirefoxOS
capabilities.setCapability("platformName", "Android");
// Java package of the Android app you want to run capabilities.setCapability("appPackage", "");
// Activity name for the Android activity you want to launch from package capabilities.setCapability("appActivity", "");
// Initialize the driver object with the URL to Appium Server passing the capabilities. Server Url may vary
driver = new RemoteWebDriver(new URL(""), capabilities);
wait = new WebDriverWait(driver, 5);
public void testSearchAppium() {
String homePageTitle = titleElement.getText();
Assert.assertEquals(homePageTitle, Most Reliable App & Cross Browser Testing Platform | Browserstack ");
WebElement LinkElement = driver.findElement(By.xpath("//body[@class='page-template-default page page-id-593 page-parent live persistent-header wpb-js-composer js-comp-ver-6.0.5 vc_responsive']")).click();
String searchPageTitle = driver.findElement(byPageTitle).getText();
Assert.assertEquals(searchPageTitle, "Search");
public void tearDown() {

In order to run Appium tests, one must specify the desired capabilities. This can either be done in the test code, or one can have them in appium.txt files. Basically, desired capabilities refer to a JSON object (a set of keys and values) sent by the client to the server. Testers can create a session for a browser with its own set of desired capabilities to have more control over the server during automation.

Run Appium Tests on Real Android Devices for Free

Since users demand high-functioning and engaging apps, Appium testing is an absolute requirement before releasing any apps. By running Appium tests on real Android devices, testers can ensure that apps are working as expected in real user conditions. Run as many tests as possible on as many real Android devices as possible to offer a consistently optimal user experience.

Appium Automation Testing Mobile App Testing

Featured Articles

How to run Appium Tests on an iOS device?

React Native and Appium – Introduction to Test Automation

Challenges of Remote Testing

BrowserStack Logo Run Appium tests on real Android and iOS devices Contact us Get Started Free