Appium Introduction : Concepts, Design, Architecture

Appium is a mobile app automation testing tool. It can be used to test apps run in iOS and android platform. It can test both native, web and hybrid mobile applications. It is open source.

Mobile native apps are those that are written using iOS or Android SDK. The so-called “mobile web application” refers to applications accessed using a mobile browser (Appium supports Safari in iOS and Chrome in Android).

And “hybrid application” refers to the native code that encapsulates a web view — use native code to interact with web page content. This can help developers develop applications using web technology, and then encapsulate them in native code.

1. The Concept Of Appium

To meet mobile automation requirements, Appium follows a philosophy that focuses on the following four requirements:

Don’t have to recompile or modify application for automation.

Don’t have to be limited to a certain language or framework to write and run test scripts.

A mobile automation framework should not duplicate the wheel of the interface. (mobile automation interfaces should be unified).

Open source, both mentally and nominally.

2. Appium Design

So how does the Appium architecture implement this philosophy? To meet the first point, the real work engine of Appium is actually a third-party automation framework. That way, we don’t need to embed Appium related or third-party code in your application. This means that the tested app is not different from the final release. Appium use following third party frameworks:

Using this client-server architecture, we can write the client in any language and send the appropriate HTTP requests to the server. Most popular language (java, python, php, javascript etc) versions of the client have been implemented so far.

The client library is simply an HTTP client that can sneak into your code in any way you like. In other words, the Appium and WebDriver clients are not technically “test frameworks” but “automation libraries”. You can use these automation libraries in your test environment!

In fact, WebDriver has become the standard for web browser automation. Why should we do something completely different for mobile? So we’ve extended the WebDriver protocol and added mobile automation-related API methods on the original basis.

3. Appium Architecture

C/S Architecture.
The core of Appium is a web server that provides a set of REST interfaces. It receives the client’s connection, listens to the command, then executes the commands on the mobile device, and then returns the execution results to client in HTTP response.In fact, this client/server architecture gives you a lot of possibilities: you can use any language that implements this client to write test code. You can put the server side in different machines. You can only write test code, and then use cloud services like Sauce Labs to execute commands.

Session.The automation process always run in one session. Client initializes a seesion to interact with server, different languages have different ways of session implementation, but eventually they all send a POST request to the server, the request contains a JSON object, which is called ” desired capabilities “. Then the server starts an automation session and returns a session ID to client user for subsequent commands.

Desired Capabilities.
The Desired capabilities are collections of key-value pairs (for example, a map or hash), and client sends these key values to server to tell the server how we want to test.For example, we can set platformName capability’s value to “iOS”, this will tell Appium server, we want an iOS session, not an Android. We can also set safariAllowPopups capability’s value to “true”, this will make sure that in Safari automatic session, we can use javascript to open new Windows.Please look at the capabilities documentation for a complete list of capabilities.

Appium Server.
Appium server is written in node.js. We can compile from source code or install directly from NPM.

Appium Client.
The Appium client library has been implemented in a lot of languages such as Java, Ruby, Python, PHP, JavaScript, and c #, all of which implement extensions to the WebDriver protocol for Appium. When using Appium, you can simply use these libraries instead of the regular WebDriver library.

Appium.app, Appium.exe
There are also a GUI encapsulated Appium server download that encapsulates all the dependencies need to run Appium server. Use this tool, you do not need to worry about how to install node.js. It also includes an Inspector tool that can help you check the application’s interface hierarchy, which is more convenient when writing test cases.