...

Though automation could sound overwhelming, it offers scalable benefits to the modern enterprise. Enterprises are continually looking for ways to improve performance levels and gain an edge over the competition.

An automated testing approach is used in almost every testing process. This isn’t surprising, as properly organized automated testing reduces the time needed for a testing process that eliminates errors and omissions in test execution caused by a human factor.

Here’s an image that signifies how automation holds the key in mobile testing, and it’s imperative for organizations to adopt an automation tool to streamline their business operations.

There is a choice of tools for automation, and each tool is unique and possesses specific characteristics.

Appium is one such tool, that’s open-source for automating mobile applications which can be Native, Hybrid and Web and supports platforms such as Android, iOS and Firefox OS.

Appium’s Architecture

The workings and architecture of Appium can go a long way, mainly if you’re using this tool regularly. Bug fixes and troubleshooting can be done quite quickly, and soon you will be finding inventive ways to work with it differently.

Appium is an HTTP server written in Node.js that creates and handles WebDriver sessions. The Appium web server follows the same approach as the Selenium WebDriver, which receives HTTP requests from client libraries through JSON and then handles requests differently, depending on the platform it’s running on.

Appium on Android

On an Android device, Appium leverages the UIAutomator framework to automate the apps. UIAutomator is a framework that’s developed by the Android developers to test the Android user interface.

Have a look at the architecture shown in the following image:

Appium supports the Android versions greater than or equal to 17; for versions earlier, it leveraged the Selendroid framework. When we execute the test scripts, Appium do sends the command to the UIAutomator or Selendroid based on the Android version.

Here, bootstrap.jar plays a vital role in a TCP server, which we canuse to send the test command to act on the Android device using UIAutomator/Selendroid.

Desired capabilities

Desired capabilities are a JSON object sent by the client to the server. It offers the capabilities for the automation session in which we are interested. It’s required to import “import org.openqa.Selenium.remote.DesiredCapabilities” library for Java to work with the required capabilities.

Installing Android SDK

We need to install the Android SDK to drive test scripts on devices. You can download the Android SDK from http://developer.android.com/sdk/index.html for your operating system.

We can set the system variables for Windows using the following steps:

  1. Follow steps 1 to 4 from the preceding section, in which we set the path for Java.
  2. Type Variable name as ANDROID_HOME and enter the Variable value of where you have your Android SDK installed. For example, C:\android-sdk.
  3. Now, we need to add the paths %ANDROID_HOME%\platform-tools and %ANDROID_HOME%\tools to the Path variable under System Variables.
  4. Click OK button to apply changes.

To verify the path, type android on the command prompt and press enter. The following window will appear:

An Android emulator

Create the AVD from the AVD Manager (you can find this under the Android SDK folder). We need to perform the following steps to create the AVD:

  1. Double-click on AVD Manager and click on the New button. The following screen will be displayed:

Sample Appium Code in C# to Launch App

Identify Object Using UI Automator

  • Go to SDK folder and open the tools
  • Open uiautomatorviewer
  • On the actual device, open the app to the page you want to automate.
  • In UI Automator Viewer, click on Device screenshot (second button).
  • Click any element on the page and look in the Node detail window
  • Leverage the information found (id, class) in Eclipse to click buttons, fill input fields

Strengths

  • Allows you to write tests that are against mobile platforms
  • Supports both iOS and Android Apps
  • One of the most versatile tools for testing any native, hybrid and web mobile apps
  • Test multiple android devices at a time
  • Doesn’t require code access or recompiling the app

Limitations

  • No support for parallel test for iOS apps
  • No option to switch off the network connection
  • No support for android version < 4.1
  • No image comparison
  • No support that will allow you Appium inspector on Microsoft Windows