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.
Are you interested in taking up for Appium Training? Enroll for Free Demo on Appium Training!
So, let’s dive into the topic and understand the usage of the Appium tool, its limitations, etc.
- What is Appium?
- Types of Mobile Apps
- Appium Architecture
- Why choose Appium for your mobile testing?
- Prerequisites to use Appium tool
- Setting up the Appium Tool on Windows
- Appium Android Emulator Setup process
- Preparing Mobile Device for Automation with Appium:
- Start automating android app using Appium:
- How to Locate Element using UI AutomatorViewer?
- What are the common Encountered errors and troubleshooting steps in Appium?
- Advantages of using Appium
- Limitations of using Appium
What is Appium Testing?
Appium is an open source tool and it is widely used for mobile application testing. It has a UI testing framework which 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 which translates Selenium scripts into UI Automation (iOS) and UIAutomator (Android) commands based on the device type and not by the OS type.
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 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.
[Related Article: Selenium WebDriver Commands]
Appium is nothing but an HTTP server which is written in node.Js
The appium architecture is the same as that of 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 windows platform. The Appium architecture is different from iOS to Android.
Appium Architecture in Detail
So, when the user is downloading 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.
What is 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.
Subscribe to our youtube channel to get new updates..!
JSON wire protocol
JSONWP is nothing but a JSON wire protocol. It is a transport mechanism which 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 a 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 which is provided by Apple for writing the test script.
- In this scenario, the Appium client can be Java or Python which connects with Appium server via JSON wire protocol.
- After a successful connection, the UI Automation will start communicating with bootstrap.js
- If we carefully observe, the bootstrap.js will execute test scenarios for the applications.
Why choose Appium for your mobile testing?
This section of the article will give out information about why testers have to use Appium tool for mobile testing.
- Appium is a sub division 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 the 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 about the basic softwares that we need to use 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.
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.
Once the download is completed, click on the exe and the Appium tool will be installed automatically.
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.
To initiate a new session, click on File> New Session Window option
A new window will open up, the user will have an option to enter the Desired capabilities and start a session.
The Appium inspector is only available for iOS and Android. The Appium inspector tool is not available for 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.
- 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.
- In column wise structure, the element hierarchy will be displayed in 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.
- Now, the user has to click on “Path” and set it to Android_Home variable which eventually points to your SDK directory.
- 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.
- 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
Start automating android app using Appium:
So, to automate the android app using Appium, please follow this process:
- First of all, download the Appium.exe to your PC.
- Run the executable file.
- 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 be defaulted 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.
- The package name is com.example.android.contactmanager
- The activity name for the Contact Manager app is com.example.android.contactmanager.ContactManager
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 are connected to the PC.
- So, select the application which you want to automate within the mobile device
- Next step is to open the UIAutomatorViewer and go the specific path: Adt-bundle-windows-x86_64-20140702sdktools
- 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.
- For the test scenario, click on “Add contact” button.
- Use the locator By.name(“Add Contact”)
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.
|Error||Command 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 adb||The 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 exception||The 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 Appium tool offers.
- Using 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 the 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 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 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 of time. It is time taking activity for the testers to execute the scripts individually.
- As per industry standard, 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.
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 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