Appium is an open source, cross-platform test automation tool for native, hybrid and mobile web apps. It supports simulators (iOS, FirefoxOS), emulators (Android), and real devices (iOS, Android, FirefoxOS).

 

Appium is an open source test automation tool developed and supported by Sauce Labs to automate native, hybrid and mobile web apps. It uses JSON wire protocol internally to interact with iOS, FirefoxOS and Android apps using the Selenium WebDriver.

 

There are many other automation tools available in market to automate mobile native apps like MonkeyTalk, Calabash and Frank, but most of these tools require an extra agent to be compiled with the application code so that the tool can interact with the mobile app. So the problem here is the app that is being tested is not the same app that will be submitted to the stores as we need to remove the automation agent libraries before submitting the app. This constraint of having an automation agent along with the application code can be overcome by using Appium automation tool.

 

Why Appium?

 

• You don’t have to recompile your app or modify it in any way or include any extra automation agent, due to use of standard automation APIs on all platforms.
• You can write tests with your favorite Dev tools using any WebDriver compatible language such as Java, Objective-C, JavaScript, PHP, Python, Ruby, C#, Clojure, or Perl with the Selenium WebDriver API and language-specific client libraries.
• You can use any automation testing framework (Ex: JUnit, TestNG).

 

Automating native, hybrid and web mobile applications for Android, FirefoxOS and iOS is a key function handled by Appium, a node.js server. The interaction between node.js server and Selenium client libraries is what ultimately works together with the mobile application. Since Appium is open source and can seamlessly run on a variety of devices and emulators, it is an apt choice for mobile test automation.

 

Appium’s Architecture

Appium is an HTTP server written in Node.js which creates and handles multiple WebDriver sessions for different platforms like iOS and Android.

 

Appium starts a “test case” on the device that spawns a server and listens for proxy commands from the main Appium server. It is almost same as Selenium server which perceives HTTP requests from selenium client libraries and handles those requests in different ways depending upon the platforms. Each vendor (like iOS and Android) has a different way and mechanism to run a test case on the device so Appium kind of hacks into it and runs the test case after listening to commands from Appium server.

 

How Appium works in iOS:

On iOS, Appium sends command to a UIAutomation script running in Mac Instruments environment. Apple provides an application called ‘Instruments’, which is used to do lot activities like profiling, controlling and building iOS apps, but it also has an automation component where one can write commands in JavaScript which uses UIAutomation APIs to interact with the app’s UI. Appium utilizes these same libraries to automate iOS Apps.

 

In the below figure, we can see the architecture of the Appium in context of iOS automation. Coming to command life-cycle, it goes like this; Selenium WebDriver picks a command form the code (Ex: element.click) and sends it in JSON format via HTTP request to the Appium server.

 

iOS

 

Appium server knows the automation context (whether iOS or Android) and sends the command to the Instruments command server which will wait for the Instruments command client (written in node.js) to pick it up and execute it in bootstrap.js within the iOS Instruments environment. Once the command is executed the Instruments command client sends back the message to the Appium server which logs everything related to the command in its console. This cycle keeps going until all the commands gets executed.

 

How Appium works in Android:

The situation is almost similar in case of Android where Appium sends commands to a UIAutomator running on the device. UIAutomator is Android’s native UI automation framework which supports running test cases directly on the device from the command line. It uses JAVA as a programming language but Appium will make it run from any of the WebDriver supported languages.

 

Android

 

In the above diagram we have Bootstrap.jar in place of bootstrap.js which represents our test case when compiled in java. As soon as it gets launched it spawns a TCP server. Here the TCP server resides inside the device and client is in the Appium process which is just opposite to the way it is in iOS.

Sampath
Sampath
Sr. QA Engineer