Learning Appium Concepts
We begin by learning the basic appium concepts to get a hands holds experience. Lets get started.
Client/Server Architecture
Appium is at its heart a webserver that exposes a REST API. It receives connections from a client, listens for commands, executes those commands on a mobile device. Further responds with an HTTP response representing the result of the command execution. Benefits offered by client/server architecture includes –
- Firstly, we can write our test code in any language that has a http client API
- Secondly, we can put the server on a different machine than our tests are running on.
- Also, we can write test code and rely on a cloud service like Sauce Labs to receive and interpret the commands.
Session
Remember, automation is always performed in the context of a session. In which case, the clients initiates a session with a server in ways specific to each library. However, they all end up sending a POST /session request to the server, with a JSON object called the ‘desired capabilities’ object. Now, at this point the server will start up the automation session and respond with a session ID used for sending further commands.
Desired Capabilities
Desired capabilities are a set of keys and values (i.e., a map or hash) sent to the Appium server. The primary objective is to tell the server the kind of automation session you may be interested in starting up. Moreover, there are various capabilities which can modify the behavior of the server during automation.
Appium Server
Appium is a server written in Node.js. In general, you can build and install from source or installed directly from NPM:
$ npm install -g appium
$ appium
The beta of Appium is available via NPM with npm install -g appium@beta. Correspondingly, it is the development version so it might have breaking changes. Remember to uninstall appium@beta (npm uninstall -g appium@beta) before installing new versions in order to have a clean set of dependencies.
Appium Clients
You may come across client libraries (in Java, Ruby, Python, PHP, JavaScript, and C#) that supports Appium extensions to the WebDriver protocol. Therefore, it is suggested to use these client libraries instead of your regular WebDriver client, while using Appium.
Appium Desktop
We can download the Appium server for any platform, with a GUI wrapper around it. Further, it comes bundled with everything required to run the Appium server, so you don’t need to worry about Node. Also, it also comes with an Inspector, that enables you to check out the hierarchy of your app. This can come in handy when writing tests.