Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20



Use Selenium Appium Automation For Mobile Apps

In this example, I will explain how to use Selenium Appium Automation for mobile app testing. 

Appium is an open source test automation framework for use with native and hybrid mobile apps. It drives iOS and Android apps using the WebDriver JSON wire protocol. 

Step 1: download the Appium Framework and sample example files provided by the site .  Click on the corresponding links to download the framework and sample files. 


Main website for downloading Appium framework

Website to download sample files and codes

Step 2: Unzip the files after downloaded. 

Step 3: download Android-SDK and set up on your PC. visit the site "" for how to setup android-sdk on your computer.  And also create an Android Virtual Device named "Default" by using AVD Manager application in the android-sdk framework. 

Step 4: run Eclipse and Import the Java->JUnit sample code from the unzipped folder. 

Java Import window

java->junit folder to import as Maven project. 

Imported Java Project Structure

Step 5: run the Appium Server by executing Appium.exe in the unzipped folder. 

Server Launched Window

Step 6: change file as needed. The code works without any changes. In this example, I changed the contact name and email information for demonstration purpose. 

package com.saucelabs.appium;

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.HasTouchScreen;
import org.openqa.selenium.interactions.TouchScreen;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteTouchScreen;
import org.openqa.selenium.remote.RemoteWebDriver;

public class AndroidContactsTest {
  public class SwipeableWebDriver extends RemoteWebDriver implements
      HasTouchScreen {
    private final RemoteTouchScreen touch;

    public SwipeableWebDriver(final URL remoteAddress,
        final Capabilities desiredCapabilities) {
      super(remoteAddress, desiredCapabilities);
      touch = new RemoteTouchScreen(getExecuteMethod());

    public TouchScreen getTouch() {
      return touch;

  private WebDriver driver;

  public void addContact() {
    final WebElement el = driver.findElement("Add Contact"));;
    final List<WebElement> textFieldsList = driver.findElements(By
    textFieldsList.get(0).sendKeys("Selenium Master");
    textFieldsList.get(2).sendKeys(" This email address is being protected from spambots. You need JavaScript enabled to view it. ");

  public void setUp() throws Exception {
    // set up appium
    final File classpathRoot = new File(System.getProperty("user.dir"));
    final File appDir = new File(classpathRoot, "../../../apps/ContactManager");
    final File app = new File(appDir, "ContactManager.apk");
    final DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
    capabilities.setCapability(CapabilityType.VERSION, "4.2");
    capabilities.setCapability(CapabilityType.PLATFORM, "WINDOWS");
    capabilities.setCapability("app", app.getAbsolutePath());
    driver = new SwipeableWebDriver(new URL(""),
    driver.manage().timeouts().implicitlyWait(300, TimeUnit.SECONDS);

  public void tearDown() throws Exception {

Step 7: run the java class as JUnit Test and observe the result. The result indicated that the test passed. 

Watch the demo video for this example.