What is Appium?

Appium is based on the Selenium WebDriver Automation API, and extends the framework to provide automation of mobile devices (iOS & Android) and also automation of Windows 10 Desktop Apps. Therefore by using WebDriver and Appium, you can automate the testing of Web, Mobile and Desktop Apps, all for free as like Selenium, it is also open-source software!

  • A powerful Open-Source Automation Tool based on the WebDriver API
  • Allows Cross-Platform and Multi-Technology Automation
  • Provides Native Application Testing for Mobile
  • Uses a Client/Server Approach like WebDriver
  • Allows you to execute tests locally or remotely
  • Extends WebDriver with support for Mobile Devices and Mobile Actions such as Gestures, Touch, Mobile Button Presses etc.

So Appium is effectively Selenium for Apps. The brain-child of Dan Cuellar who started development in 2012. In January 2013 Sauce Labs decided to fully back Appium and provide more developer power.  In May 2014, version 1.0 was released, which stood as a milestone in Appium’s development. It was given various awards and became the most popular open-source cross-platform mobile automation framework.

Mobile & multi-device (tablets & other devices) far outweighs desktop web browsing now, so testing multiple devices is crucial. Most of us spend more time on mobile apps than any other kind of technology, so testing of apps and mobile web browsing is now essential.

  • Apps account for 89% of mobile media time, with the other 11% spent on websites
  • Tablet devices account for the highest add-to-cart rates on e-commerce websites
  • Google says 61% of users are unlikely to return to a mobile site they had trouble accessing and 40% visit a competitor’s site instead

So utilizing a good test automation tool to accelerate our mobile testing is ever-more important, and we believe that Appium provides the future for mobile testing.

 

Technologies Supported

Platforms:

  • Windows, Mac OSX, Linux

Technologies:

  • Android Devices/Emulators
  • iOS Devices/Emulators
  • Windows 10 Applications (WPF, WinForms, Win32, Universal Windows Platform UWP)

Mobile Application Technologies:

  • Native Apps, Mobile Web Apps, Hybrid Apps

 

Benefits of using Appium

  • Based on WebDriver which is a candidate for W3C Standard
  • Tests applications natively, no need to instrument applications
  • Supports multiple technologies – Web, Windows Apps, iOS, Android
  • Supports multiple languages – Java, C#, PHP, Python, JavaScript, Ruby
  • Can use whatever Testing Framework you choose – NUnit, JUnit, xUnit etc.
  • Choose the IDE you would like to use – Visual Studio, Eclipse, IntelliJ, SharpDevelop etc.
  • Tests can be executed locally or on remote machines
  • It’s Open-Source!

Google Trends for Appium

Appium Google Trends

How does Appium work?

Appium provides automation by vendor-developed native UI Automators. This means that it is using vendor-developed automation, making it more robust and hopefully providing full vendor-support going forward. Here are the automators it utilizes:

As mentioned earlier, it uses a client/server approach just like Selenium. There are two choices of servers:

  • Appium Desktop – A GUI based point & click server implementation that provides a step recorder and a tool for inspecting mobile elements – great for beginners
  • Appium Server – This is the main development project, it is a command-line implementation and requires nodejs to run

Many people start with the Appium Desktop Server, as it is simple to install and use.

For the client, you simply download the required language client libraries:

  • WebDriver Libraries
  • Google GSON Library
  • Appium Library

 

What do Appium scripts look like?

Let’s have a look at an example script. The script below uses Java bindings, and this example tests the calculator app on a physical Android phone:

package com.edgewords.appium.demo.galaxyS5;

import static org.junit.Assert.*;

import org.junit.After;

import org.junit.Before;

import org.junit.Test;

import org.openqa.selenium.*;

import org.openqa.selenium.remote.CapabilityType;

import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.android.*;

import java.net.URL;

import java.util.concurrent.TimeUnit;

 

public class CalcTest {

AndroidDriver driver;

@Before

public void setUp() throws Exception {

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability("deviceName", “Galaxy S6");

capabilities.setCapability("udid", "892db771");

capabilities.setCapability(CapabilityType.BROWSER_NAME, "");

capabilities.setCapability(CapabilityType.VERSION, "6.0.1");

capabilities.setCapability("platformName", "Android");

capabilities.setCapability("appPackage", "com.sec.android.app.popupcalculator");

capabilities.setCapability("appActivity", "com.sec.android.app.popupcalculator.Calculator");

 

driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

}

@After

public void tearDown() throws Exception { driver.quit();
}

@Test

public void test() {

driver.findElementByAccessibilityId("clear").click();

driver.findElementByAccessibilityId("8").click();

driver.findElementById("com.sec.android.app.popupcalculator:id/bt_add").click();

driver.findElementByAccessibilityId("6").click();

driver.findElementByAccessibilityId("equal").click();

 

String strAns = driver.findElementById("com.sec.android.app.popupcalculator:id/txtCalc").getText();

System.out.println("Answer is " + strAns);

}

}

The above script is using Java bindings, but there are many more languages supported. When you look at the @Test code you will see the similarities to WebDriver. If we look at the @Before region you will see that we set a number of ‘Desired Capabilities‘. These are crucial to Appium and tell it what device we will be testing against, the OS version and the application we wish to invoke and automate. Another part to note is the driver; in WebDriver we would instantiate an appropriate web driver such as ChromeDriver, in Appium we have a drivers for: iOSDriver, WindowsDriver, AndroidDriver, AppiumDriver and instantiate the appropriate one for the technology we are testing.

If you have experience of Selenium WebDriver, you will very quickly be up and running with Appium after our introductory training course.

 

Resources

 

Appium courses from Edgewords:

  • Appium Introduction – 2 days, Classroom, London

 

Why use Edgewords?

Edgewords has been delivering training in automated testing for over a decade and is recognised as one of Europe’s leading providers in this field. All of our trainers have at least 10 years testing experience, so can provide expert advice on industry best practices.

All of our courses are practical, written by testing consultants, so you really learn how to develop real-world tests and overcome common problems you will experience along the way.

Comprehensive workbooks are provided that act as a great resource after the course when you need to start developing automated tests on your own.

Simply call us on +44 (0)333 939 8884 or submit an enquiry form here and we will assist you in finding the most suitable course for your needs.