What is Appium
Appium is cross-platform and allows you to write against multiple platforms because it allows for code reuse between Windows, Android and iOS test suites. Being an open source tool, it is the perfect choice for automating native, mobile web and hybrid applications on their respective platforms.
This is the Appium philosophy. All the mobile automation needs are based on the philosophy in these four tenets:
1. You shouldn’t have to recompile your app or modify it in any way in order to automate it.
2. You shouldn’t be locked into a specific language or framework to write and run your tests.
3. A mobile automation framework shouldn’t reinvent the wheel when it comes to automation APIs.
4. A mobile automation framework should be open source, in spirit and practice as well as in name!
How does Appium do all this?
Appium is highly regarded in the mobile testing world because it makes your mobile app regression testing easy. This is a great boon for large applications where you have continuous feature updates and new functionalities. And it allows you to use any testing framework because of its bevy of multiple platforms and languages.
Now let’s get a tad deeper into the basics of Appium. Appium is an HTTP web server written in Node.js platform, and evolved from Selenium. When Appium is downloaded and installed, a server will be set up on your machine, exposing a REST API. It drives the iOS and Android session using WebDriver JSON. You must, however, pre-install Node.js on the system before initialising Appium Server.
Selenium WebDriver and JSON Wire Protocol let you have internal interaction with iOS and Android applications.
Appium is a client-server architecture. This means that it receives connections from a client, listens for commands, performs those commands on the mobile device, responds with an HTTP response representing the result of command execution. Since Appium is a client/server architecture, you have a lot of possibilities, because you can easily use any of the Appium client libraries, even though you can write tests codes in a language with http client API.
There are other automation tools in the market like MonkeyTalk, Calabash, Frank, KIF, etc. that help you automate mobile native apps, but you need extra agents compiled in your application to make them interact with the mobile app. This is a disadvantage because it becomes slightly different from the apps you are submitting in the App Store, and you would have to remove those automation agent libraries and only then submit the app.
It is also worth noting here that Appium is at heart a web server that exposes a REST API.
- It receives connection in the form client
- Follows the commands you issue
- Execute the commands on the device
- Responds back with an HTTP response that represents the result of command execution.
The Concepts of Appium
Since you have a client/server architecture, there are a lot of possibilities with Appium. You can use one of the Appium client libraries or you can write the test code in any language that has an HTTP client API. You can put the server on any machine, irrespective of the machine your test is running on. Write the test code and rely on SauceLabs, a cloud library, to receive and interpret the commands.
A set of keys and values are sent to the Appium server to specify the type of automation session to be initiated. It is also possible to modify the server behaviour during automation.
All the automation tasks are performed under the context of a session. When the client initiates a session with a server, a Post/session request is sent to the server with a JSON object called the Desiredcapabilities object. This way, the session starts with an automation session and shows a session ID through which further commands are sent.
Appium is written in Node.js. There are two ways to do this — it can be built and installed from the source, or installed directly from NPM:
$ npm install -g appium
You can download the GUI wrappers around Appium server. They have all that you need to run the Appium server, so don’t worry about the Node. An additional benefit is the possibility to check the hierarchy of your app when writing and running the tests. This is done with the help of Appium provided Inspectors.
Advantages of Using Appium
- No Code Change Required: You can use the same source code while running the tests, so you don’t require access to any source code or library. Test your native, hybrid and web apps with the same codes (there is no need to modify them) you are going to ship.
- Multi Platform Support: Appium uses the JSON wire protocol to interact with Android and iOS along with Selenium WebDriver. To automate iOS apps, Appium makes use of the libraries provided by Apple with the help of an application called Instruments. In Android too, the process is almost similar where Appium proxies the automation command to the UIAutomator test case running on the device. Android has a native UI automation framework called UIAutomator which supports running JUnit test cases from the command line directly into the device.
- When you invest in the WebDriver protocol, it means you are leaving the proprietary stack and have explored the benefits of using a single, free and open protocol for testing. This has already become the web standard for testing.
- Open Source: Being an open source testing framework is one of the biggest benefits of Appium as it supports Simulators or Emulators, and of course, native, hybrid and web application testing of IOS and android. The highly active community of developers makes it easy for new developers to clear their doubts.
Appium works almost like the Selenium server which listens and understands http requests from Selenium client libraries, and then performs the tasks in different ways depending on which platform it is testing on. Similarly, Appium starts a test case on a device spawning a server, performing tasks after listening to the proxied commands from the main Appium server.
Other major benefits of Appium with an Automation framework are:
1. Better quality of product — Appium testing helps you release high quality, functional apps when compared to other frameworks because the testing is so accurate and realistic.
2. Faster release cycles — As everything is done automatically, there is no intervention or halt while the testing is going on, and you can enjoy faster release cycles.
3. More features — As the overall testing time is reduced, Appium allows you to implement more features per release. You can test more features and updates to your app, because the overall testing time is reduced. The number of features added in your app will not increase the testing time.
4. “Closest to live” testing scenarios — Since the app is tested as it is, you don’t have to add extra codes in it. This gives you a real life scenario of how your app will perform when it gets into user’s hands.
Let us get started on testing a React Native App with Appium. We’ll use the Python library of Appium to achieve the automation.
Appium description copied from HackerNoon website from this blog post.