Appium Tutorial — A Complete Guide To Instal & Use Appium

Archana Choudary
Edureka
Published in
7 min readMar 8, 2019

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:

  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!

Types of Mobile Applications

As discussed in the first paragraph, you must have realized that Appium has the ability to deal with all sorts of applications. Let’s understand the different types of applications.

Native 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.

Web Applications

These kinds of applications used to be really famous until the concept of native applications came along. Web applications as the name suggests, run on a browser. Since they run on a browser, they generally don’t require any sort of complicated installation and the development process is cheap from a budget perspective too. Since the application is not developed for a particular platform, web-based development languages like HTML/CSS/JavaScript are used for their development.

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

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

Now, let us discuss the architecture and design of Appium in this article.

Appium 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. 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:

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.

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.

  1. Download the following-

2. Install Java on your system. Don’t forget to set the environment variables!

3. Install Android Studio on your system by running the installer and then create a new project.

4. Extract the client library. Keep them separately in a file along with the Appium jar files.

5. Switch to the project view in Android studio.

6. 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.

7. 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 wish to check out more articles on the market’s most trending technologies like Python, DevOps, Ethical Hacking, then you can refer to Edureka’s official site.

Do look out for other articles in this series which will explain the various other aspects of Software Testing.

1.Mobile Application Testing

2. Software Testing Tools

3. Types of Software Testing

4. JMeter Tutorial

5. Load Testing using JMeter

6. What is Functional Testing?

7. Automation Testing Tutorial

8. Functional Testing vs Non-Functional

9. JMeter vs LoadRunner

10. Regression Testing

11. Performance Testing Life Cycle

12. JMeter Plugins

13. Appium Architecture

14. How to Perform Stress Testing using JMeter on Websites?

Originally published at www.edureka.co on March 8, 2019.

--

--

Archana Choudary
Edureka

Inquisitive person by nature, technology fancier, an avid reader and writer of tech blogs. Especially, on cloud computing and software testing.