Appium Tutorial for Beginners

Appium is a mobile application UI testing framework that is open-source and freely available. It offers automation tests on both physical devices and emulators or simulators and supports native, web  and hybrid application testing. This tutorial walks you through the fundamentals and advanced features of the Appium Automation testing tool.

Appium is one of the open-source tools which is widely used for automation testing of mobile apps. The tool is used to test apps on iOS and Android platforms. Appium is suitable for testing all kinds of mobile applications, i.e. Native applications build on iOS and Android platforms, hybrid mobile apps, and web browser-based mobile apps.

Appium Tutorial - Complete Guide for Beginners

 Following are the topics we will be covering in this article
  1. What is Appium?
  2. Types of Mobile Apps
  3. Appium Architecture
  4. Why choose Appium for your mobile testing?
  5. Prerequisites to use Appium tool
  6. Setting up the Appium Tool on Windows
  7. Appium Android Emulator Setup process
  8. Preparing Mobile Device for Automation with Appium
  9. Start automating android app using Appium
  10. How to Locate Element using UI AutomatorViewer?
  11. What are the common Encountered errors and troubleshooting steps in Appium?
  12. Advantages of using Appium
  13. Limitations of using Appium

What is Appium Testing?

Appium is an open-source tool and is widely used for mobile application testing. It has a UI testing framework that works for iOS and Android mobile applications. It supports all types of mobile applications, i.e. Native, Hybrid, and Web applications. There is no dependency on the mobile OS.

Appium tool itself has a framework that translates Selenium scripts into UI Automation (iOS) and UIAutomator (Android) commands based on the device type and not by the OS type.

It supports various languages that consist of Selenium client libraries. For example Java, Python, C#, JavaScript with Node. js, etc.

Are you interested in taking up for Appium Training? Enroll for Free Demo on Appium Course!

Types of Mobile Apps

Based on the coding platforms, mobile apps are differentiated as follows:

Native Apps: Native apps are those where the mobile applications are built on iOS SDK and Android SDK.

Hybrid Apps: Using cross-platform coding platforms, the developers will be able to write the code and this can be eventually used for iOS, Android platforms. The codebase will be the same and the users will be able to generate iOS and Android apps separately. 

Web Apps: Mobile applications are built in such a way that they access mobile browsers and work exactly like an application. Appium supports the Safari browser for iOS platforms and chrome in the Android platform.

Appium Architecture

Appium is an HTTP server but written in NodeJS which internally creates and also handles the web driver sessions. If we compare the Appium web server and the Selenium Web Driver, the approach is very similar.

So basically, the Selenium Web driver actually receives the HTTP requests from the client libraries via JSON, and then it handles these requests differently.

Appium is nothing  but an HTTP server that is written in node.Js

The appium architecture is the same as that of the Selenium Webdriver Server. So, basically, this is how the Appium tool works:

  • All the requests from client libraries will be received.
  • The commands are executed on emulators and target devices.
  • Sends HTTP responses.

The Appium tool only supports iOS and Android and doesn’t support the Windows platform. The Appium architecture is different from iOS to Android.

Appium Architecture in Detail

So, when the user is downloading the Appium tool, they are actually downloading the server. Further, when the scripts are executed, the HTTP requests go in JSON format to the Appium server. Further, the Appium server sends this information to the instruments. So, if the Appium server sends the commands to iOS devices, then it needs the bootstrap.js file which will help to automate the iOS apps.

In the same manner, if the Appium server sends the commands to Android, then these commands are further sent across to UI Automator. To support UI Automator, the system needs a bootstrap Jar.

Related Article: Appium Vs Selenium Vs Calabash

What are UI Automator and UI automation API?

UI Automation API is nothing but a service provided by Apple where the users can write the test scripts and ultimately iOS apps can be automated.

UI Automator API is nothing but a framework developed by Android developers so that the testers can test within the Android interface. The below image will give you a pictorial representation of the Appium Architecture.

Appium Architecture

JSON Wire Protocol

JSONWP is nothing but a JSON wire protocol. It is a transport mechanism that is created by web driver developers.  For this wire protocol, a standard set of predefined endpoints are made available via RESTful APIs.

Appium for Android:

  • In this section, let’s see how Appium is used for the Android platform.
  • When Appium is used on the Android platform, it specifically uses the UIAutomator framework which will help to automate the apps. This framework (i.e. UI Automator) is built by Android developers to test the Android user interface.
  • The Appium client can be any one of these: C# or Java or Python.
  • Then it connects with the Appium server and the interaction happens through JSON wire protocol.
  • After a successful connection, the UI Automator will start communicating to bootstrap.jar which is executed in Emulator or Real device responsible for checking on client operations.
  • If we observe carefully, the bootstrap.jar actually plays the role of TCP server.

Appium for iOS:

  • In this section, let’s see how Appium is used for iOS.
  • When Appium is used on the iOS platform, it uses the UI Automation framework. UI Automation is a simple JS library that is provided by Apple for writing the test script.  
  • In this scenario, the Appium client can be Java or Python which connects with the Appium server via JSON wire protocol.
  • After a successful connection, the UI Automation will start communicating with bootstrap.js
  • If we carefully observe, bootstrap.js will execute test scenarios for the applications.
Related Article: Appium Interview Questions

Why choose Appium for your mobile testing?

This section of the article will give out information about why testers have to use the Appium tool for mobile testing.

  • Appium is a subdivision of Selenium Web driver JSONWP.
  • Handling this tool will be easy for testers who are already aware of the Selenium tool. So, the learning curve is comparatively less. 
  • It is an industry-standard tool for mobile app testing. As of now, selenium has dominated web-based test automation for a few years now.
  • A lot of major companies are investing their time and efforts to implement Appium as a standard tool for their mobile-based testing efforts.
  • It is a widely appreciated mobile test automation tool because Appium was offering more than its competitors.
  • No need of adding any additional frameworks so, that means, that the testers are testing the real mobile apps which are ready to ship.

Prerequisites to use Appium tool

In this section of the article, we will be discussing the basic software that we need to use the Appium tool.

  • First of all, install the Android SDK (Studio) edition
  • Have to install the Java Development Kit
  • Install Eclipse
  • Install  TestNG for Eclipse, so before doing this make sure Eclipse is definitely installed.
  • Selenium server JAR should be installed. When we are installing the selenium server, the user doesn’t need to install JS, because, by default, the Selenium server comes with Node.exe and NPM.
  • Install the Appium client library
  • Check the APK App info on Google Play
  • Last but not least, install Appium Desktop.

MindMajix Youtube Channel

Setting up the Appium Tool on Windows

The following process will help you understand the step-by-step process to install the Appium tool on your Windows and Mac machines.

Go to the Appium website, http://Appium.io/, and download the tool.

For windows, please download the exe file. If you are working on MAC, then you need to download dmg file. 

Appium Tool on Windows

Once the download is completed, click on the exe and the Appium tool will be installed automatically. 

Appium tool

The Appium server popup will be displayed with the default host and port number. 

Click on the server start button, based on this, the new server will be launched with the host and port number provided. The user will be able to see the server log output as well.

Appium server

To initiate a new session, click on the File> New Session Window option

Appium

A new window will open up, the user will have an option to enter the Desired capabilities and start a session. 

Appium Tutorial

Appium Inspector:

The Appium inspector is only available for iOS and Android. The Appium inspector tool is not available for the Windows platform. Even though the user launches the Appium server, it will fail to launch the inspect elements and ultimately doesn’t work.

The step by step guide will help the user to understand the process is given below:

First of all, download the Appium server.

  • Start the server with the default port 4725 and IP Address as 0.0.0.0
  • Select the .app files from local and test
  • To enable the “Choose” button, the user has to check the “App Path” checkbox.

Appium server

  • If it is a Mac machine, start the simulator.
  • Clicking on the “Launch” button which is available on the top right-hand corner will enable a blue color icon. Clicking on this icon will open up Appium inspector and the simulator will open simultaneously with a preselected application.

Appium

  • In column-wise structure, the element hierarchy will be displayed in Appium inspector.

Appium inspector

  • To top the recording, click on the “Stop” button.

Appium Android Emulator Setup process:

Open “Control Panel”> System and Security> System from the available left panel.  
Click on “Advanced Systems Settings” a new window will appear.
Click on “Advanced” tab
Click on “Environment Variables” button available at the bottom of the screen.

Appium Android Emulator

  • Now, the user has to click on “Path” and set it to Android_Home variable which eventually points to your SDK directory.

Appium Android Emulator

  • Make sure to attach an Android device where the debugging mode/option is set to “Enable”
  • Run the “abd devices” to see the devices which are connected.
  • Next is to go to the specific directory by clicking on Appium .exe file.
  • Click on “Launch” without changing the IP address and the host details which are displayed below.
  • Now, click on “Start” button, and this will initiate the Appium server that was available on the system.

Preparing Mobile Device for Automation with Appium:

Have the mobile testing device handy and connect it to the PC via USB. 
Make sure to enable the developer mode on the mobile phone, this needs to be done before automating the application. 

The Steps to follow to enable developer mode on Android Phone or Tablet:

  • Go to the Settings tab. Select the “About” option and then tap on “Software Information”. Tap on the “More” option.
  • Tap on “Build Number” option for about 7 times so that the developer options are enabled.
  • Now get back to the Settings option and make sure to see “Developer Options”.
  • Finally, turn on the USB debugging option.

Mobile Device for Automation with Appium

  • The next step is to download and install the USB drivers for mobile testing devices on to your personal computer.
  • In the adb terminal, look for ‘adb devices”.  C:UsersNEERAJ>adb devices
  • List of devices that are connected will be displayed

TA93305GOL device

Mobile Device for Automation with Appium

Start automating android app using Appium:

So, to automate the android app using Appium, please follow this process:

  • First of all, download Appium.exe to your PC.
  • Run the executable file. 

automating android app using Appium

  • Pass on the Device Name in the Android settings. 
  • Make sure not to change the Port number or any other settings within the general settings icon. 
  • When the Appium server starts, the port address will default to 4723.
  • Within the Android settings,  set the APK path to the location where the APK file is located. 
  • Connect the phone to the PC and also make sure to turn on the debug mode.
  • Open up the command prompt.
  • Type in “abd logcat” command.
  • Now, open the phone and press CTRL + C in the command prompt.

automating android app using Appium

  • The package name is com.example.android.contactmanager
  • The activity name for the Contact Manager app is com.example.android.contactmanager.ContactManager

automating android app using Appium

If we double-check, the essential information for Appium is populated ( the essential information is listed below)

  • Mobile Device Name
  • Package Name
  • Launch Activity

How to Locate Element using UI AutomatorViewer?

In order to automate the app, we need to find out the elements that interact with the app. For this, we need to use UI AutomatorViewer.

  • Next is to connect the mobile device in which the app is installed to a personal computer.
  • Go to Terminal and type “abd devices”. This will show all the available devices list that is connected to the PC.
  • So, select the application which you want to automate within the mobile device
  • The next step is to open the UIAutomatorViewer and go the specific path: Adt-bundle-windows-x86_64-20140702sdktools

Locate Element using UI AutomatorViewer

  • Before going to the next step, make sure that the application is launched and the UIAutomatorViewer is also launched. Then, click on “Device Screenshot”.
  • Using this option, the system will take a screenshot of all the available elements within the App.

UI AutomatorViewer

  • For the test scenario, click on the “Add contact” button. 

Locate Element using UI AutomatorViewer

  • Use the locator By.name(“Add Contact”)

Locate Element using UI AutomatorViewer

  • To find out the contact name use (“android.widget.EditText”)

What are the Common Encountered errors and troubleshooting steps in Appium?

The below table shows the common errors that most of the testers encounter while implementation and execution.

ErrorCommand to use
How to find out XPath in the mobile application?Using “UIAutomatorviewer” you can find out XPath in the mobile application.
Error: could not find adbThe setup process should be appropriate. Within the SDK root directory, “Environment Variables” the “Path” should be configured.
Error: Desired name and platform name details are required.Firstly, the user has to make sure that they add the desired capabilities. For example:
Add device name, platform name in Appium script.
Session not created exceptionThe user has to check and apply the correct path and they have to restart the Appium server.

Advantages of Using Appium

The below section will discuss all the advantages that the Appium tool offers.

  • Using the Appium tool, it is easy for the testers to use the same automation framework irrespective of the type of mobile apps (i.e. native app, hybrid apps, web apps). It is a user-friendly tool for testers because they can use a single tool to test different types of mobile applications.
  • No need to recompile the code frequently to execute the automation testing. It saves a lot of quality time for the developers.
  • The testers will be able to use this tool which supports real mobile devices, simulators, and emulators. Doing this way it helps the testers to provide accurate feedback and most importantly, the results are reliable.
  • Without adding any additional components, the testers will be able to automate the mobile app testing very easily.
  • With the help of the Appium inspector tool, the testers will be able to use the record and playback option which helps to speed up the testing efforts.
  • The users will be able to execute the testing efforts without actually using server machines
  • The webdriver libraries can be easily integrated and the test scripts can be written in various different programming languages.

Limitations of using Appium

The below section will discuss all the disadvantages of the Appium tool.

  • It doesn’t support Android older versions. If the testers have to test the mobile apps specifically built for Android 4.1 Lollypop, it is not straightforward.
  • It doesn’t provide a provision where multiple scripts can be executed in multiple simulators at a single point in time. It is time taking activity for the testers to execute the scripts individually.
  • As per industry standards, testing tools offer image recognition capabilities so that they can evaluate the gaming applications and mobile apps in detail. But, Appium cannot detect the images automatically and needs external support.
  • The tool doesn’t go well with the common gestures, for example, double-clicking. It becomes a nightmare for the testers to test the application, especially in error handling situations.

Conclusion

In general, they are a lot of options provided by Appium for mobile app testers, so whether it is a native app or hybrid app, the tool can be used efficiently. With any test automation tool available in the market, they have their advantages and disadvantages, it is the same case with the Appium tool. So, while opting for any test automation tool, one has to definitely check the compatibility, and based on the requirement, they can consider using Appium.

Explore Appium Sample Resumes! Download & Edit, Get Noticed by Top Employers!

Course Schedule
NameDates
Appium TrainingOct 15 to Oct 30View Details
Appium TrainingOct 19 to Nov 03View Details
Appium TrainingOct 22 to Nov 06View Details
Appium TrainingOct 26 to Nov 10View Details
Last updated: 29 Jun 2024
About Author

Ravindra Savaram is a Technical Lead at Mindmajix.com. His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.

read less