Automation is the new jazz. An array of things get automated including emails, google forms, web-scraping and even software testing. In this Appium tutorial, I am going to write up about Appium, a tool that has been a favourite in the mobile app testing automation testing industry for a host of reasons. Below are the topics discussed in this Appium Tutorial :
- What is Appium?
- The Philosophy of Appium
- Types of Mobile Applications
- Appium vs Selendroid vs Robotium
- Appium Architecture
- Appium Installation with Android Studio
Let us start off our Appium tutorial with a quick introduction to the tool itself.
What is Appium?
Appium is an open source, cross-platform automation testing tool. It is used for automating test cases for native, hybrid and web applications. The tool has a major focus on both Android and iOS apps and was only restricted to the mobile application testing domain. Recently, a few updates back, Appium also announced that they will support the testing of desktop applications for windows.
Appium is developed and maintained by sauce labs. Currently, Appium version 1.10 is being distributed. Appium first started off as a command line based testing service that can be installed using node.js. In their latest release, named ‘Appium desktop’ they have released a robust and refined tool with an intuitive graphical user interface. Appium desktop comes with an application element inspector which we will get to later in this Appium tutorial.
Philosophy of Appium
Appium is a rising star in the mobile test automation landscape. When it comes to mobile test automation, in many ways the industry is still figuring out what the best approaches. With Appium, they have had the benefit of lessons learned from early automation solutions that didn’t quite work as well as they had hoped. Some of these lessons are nicely summarized in Appium’s four-point philosophy:
- You shouldn’t have to recompile your app or modify it in any way in order to automate it.
- You shouldn’t be locked into a specific language or framework to write and run your tests.
- A mobile automation framework shouldn’t reinvent the wheel when it comes to automation APIs.
- A mobile automation framework should be open source, in spirit and practice as well as in name!
Types of Mobile Applications
As discussed in the first paragraph, you must have realised that Appium has the ability to deal with all sorts of applications. Let’s understand the different types of applications.
Applications that are developed, keeping a certain platform in mind are called native applications. Native applications are developed using specific software development kits and tend to be performance focused. Native apps are generally the way to go if the development budget is not an issue. Some advantages of native applications are as follows –
- Excellent performance
- They generally tend to look refined and polished
- Native applications seamlessly integrate with device hardware
- Most native applications have an intuitive UI/UX
Some examples of native applications include Spotify, Snapchat, Pinterest, Skype.
Below is a list of advantages of web applications –
- Lower development cost
- Easier to maintain
- Web-apps don’t need to be approved by application marketplaces
- No installation or user updates
Examples of successful web applications include Ali Express, Flipkart Lite and Washington Post.
Hybrid applications merge the best of native and web applications. While these applications can be downloaded from the play store and can also access all the features of the device; they are in actuality a web application on the inside. They are developed using simplistic web-development languages like HTML and CSS. This allows them to run on any platform.
Below is a list of advantages of hybrid applications –
- They only have one codebase to manage
- App development doesn’t take too long
- Easy to scale to another platform
- Access to complete device features just like a native app
Some example of hybrid apps are OLA, Basecamp, Instagram, Yelp etc
Appium vs Selendroid vs Robotium
|Free and Open Source||Free and Open Source||Free and Open Source|
|Supports both iOS and Android||Supports only Android||Supports only Android|
|No need for app source code or library||Need app source code||Need app source code/library|
|Doesn’t reinstall the application||Application reinstalled||Small changes in Robotium code leads to a complete rebuild|
|Supports multiple frameworks and programming languages||Compatible with Selenium and Jenkin||Supports java only. Not compatible with selenium at all|
|Strong & Active community||Community not as strong as Appium||Not such a proactive community|
Now, let us discuss the architecture and design of Appium in this Appium tutorial.
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. The tester writes his test scripts which are executed on the device or emulator by sending them as requests to the Appium server. 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 into it and run this test case after listening commands from Appium server.
How Appium works in iOS:
In the above figure, we can see the architecture of the Appium in context to iOS automation. If we talk about a command life-cycle, it goes like, Selenium web driver picks a command from the code and sends it in form of JSON via an HTTP request to the Appium server. Appium server knows the automation context like the iOS and Android and sends this 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 command client sends back the message to the Appium server which logs everything related to the command in its console. This cycle keeps going till the time all the commands get executed.
How Appium works in Android:
The situation is almost similar in case of Android where Appium proxies command to a UIAutomator test case running on the device. UIAutomator is Android’s native UI automation framework which supports running JUnit test cases directly into 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.
In the above diagram we can see, here 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.
Appium Installation with Android Studio
No Appium tutorial is complete without an installation guide. So here’s how you can install Appium using android studio.
- Download the following-
- Install Java on your system. Don’t forget to set the environment variables!
- Install Android Studio on your system by running the installer and then create a new project.
- Extract the client library. Keep them separately in a file along with the Appium jar files.
- Switch to the project view in Android studio.
- Now select the files you had extracted in step 4 and put in the lib folder under the app directory. Then select them all and add them as a library.
- Once you have added the files as a library, you should see a build.gradle file in the app folder. Double click that and then go and rebuild your project. Once the project is rebuilt successfully it means you have installed Appium on your system with Android studio.
This brings us to the end of this Appium Tutorial. If you want to learn more about the world of mobile application testing you could read up my other blog. If you are interested in reading some other blogs on various trending technologies, you could check out our blog catalogue.
If you wish to learn Software Testing and build a colourful career, then check out our Selenium Certification Course which comes with instructor-led live training and real-life project experience. This training will help you understand software testing and selenium in depth and help you achieve mastery over the subject.