Wednesday, October 28, 2015

APPIUM - Mobile App Automation

What is APPIUM


Appium is an open-source tool you can use to automate mobile native, mobile web, and mobile hybrid applications on iOS and Android platforms.

Mobile native apps are those written using the iOS or Android SDKs.

Mobile web apps are web apps accessed using a mobile browser (Appium supports Safari on iOS and Chrome on Android).

Mobile hybrid apps have a native wrapper around a “webview” – a native control that enables interaction with web content.

Appium is “cross-platform”, it allows you to write tests against multiple platforms (iOS, Android), using the same API.

Appium is tool developed and supported by Sauce Labs to automate native and hybrid mobile apps. It uses JSON wire protocol internally to interact with iOS and Android native apps using the Selenium WebDriver.



Note: There are many other automation tools available in market to automate mobile native apps like MonkeyTalk, KIF, Calabash and Frank but most of those tools require an extra agent needs to be compiled with your application code so that the tool can interact with the mobile app. So here the problem is the app which you will be testing is not the same app which you will be submitting in the App Store as you would need to remove those automation agent libraries before submitting the app.

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 proxied commands from the main Appium server. It is almost same as Selenium server which perceives http requests from selenium client libraries and it handles those requests in different ways depending upon the platforms. Each vendor like iOS and Android have a different way and mechanism to run a test case on the device so Appium kind of hacks in to it and run this testcase after listening commands from appium server.

APPIUM Design Concepts

  • Appium is an 'HTTP Server' written using Node.js platform and drives iOS and Android session using Webdriver JSON wire protocol. Hence, before initializing the Appium Server, Node.js must be pre-installed on the system.
  • When Appium is downloaded and installed, then a server is setup on our machine that exposes a REST API.
  • It receives connection and command request from the client and execute that command on mobile devices (Android / iOS).
  • It responds back with HTTP responses. Again, to execute this request, it uses the mobile test automation frameworks to drive the user interface of the apps. Framework like:-
  • Apple Instruments for iOS (Instruments are available only in Xcode 3.0 or later with OS X v10.5 and later)
  • Google UIAutomator for Android API level 16 or higher
  • Selendroid for Android API level 15 or less



JSON
JavaScript Object Notation (JSON) is used to represent objects with complex data structures. It is used primarily to transfer data between a server and a client on the web. It has very much become an industry standard for various REST web services, playing a strong alternative to XML.


How Appium works in iOS:


On iOS, Appium proxies command to a UIAutomation script running in Mac Instruments environment. Apple provides this 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 we can write some commands in javascript which uses UIAutomation APIs to interact with the App UI. Appium utilizes these same libraries to automate iOS Apps.

Appium

How Appium works in Android:


The situation is almost similar in case of Android where Appium proxies commands to a UIAutomator test case running on the device. UIAutomator is Android’s native UI automation framework which supports running junit test cases directly in to 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.

Appium

APPIUM Inspector
Similar to Selenium IDE record and playback tool, Appium has an 'Inspector' to record and Playback. It records and plays native application behavior by inspecting DOM and generates the test scripts in any desired language. However, currently there is no support for Appium Inspector for Microsoft Windows. In Windows, it launches the Appium Server but fails to inspect elements. However, UIAutomator viewer can be used as an option for Inspecting elements.

Limitations using APPIUM

  • Appium does not support testing of Android Version lower than 4.2
  • Limited support for hybrid app testing. eg: not possible to test the switching action of application from the web app to native and vice-versa.
  • No support to run Appium Inspector on Microsoft Windows.

1 comment: