Appium: The Complete Guide Tutorial For Free | CHECK-OUT
Last updated on 07th Jul 2020, Blog, Tutorials
What is Appium?
APPIUM is a freely distributed open source mobile application UI Testing framework. Appium allows native, hybrid and web application testing and supports automation test on physical devices as well as an emulator or simulator both. It offers cross-platform application testing, i.e. single API works for both Android and iOS platform test scripts.
- Appium is an ‘HTTP Server’ written using a Node.js platform and drives iOS and an Android session using Webdriver JSON wire protocol. Hence, before initializing the Appium Server, Node.js must be pre-installed on the system.
- When Appium is downloaded and installed, then a server is set up on our machine that exposes a REST API.
- It receives connection and command request from the client and executes that command on mobile devices (Android / iOS).
- It responds back with HTTP responses. Again, to execute this request, it uses the mobile test automation frameworks to drive the user interface of the apps. A framework like:-
- Apple Instruments for iOS (Instruments are available only in Xcode 3.0 or later with OS X v10.5 and later)
- Google UIAutomator for Android API level 16 or higher
- Selendroid for Android API level 15 or less
Prerequisite to use APPIUM
- Install ANDROID SDK (Studio)
- Install JDK (Java Development Kit)
- Install Eclipse
- Install TestNg for Eclipse
- Install Selenium Server JAR
- Appium Client Library
- APK App Info on Google Play
- js (Not Required – Whenever Appium server is installed, it by default comes with “Node.exe” & NPM. It’s included in Current version of Appium.)
- Install Appium Desktop
Step 1: Java Installation and Setup
With Appium, you would need to write automation test scripts that interact with the screens and controls (buttons, text boxes etc) in your mobile app and perform actions on them. We would use Java to write these automation scripts.
Step 1.1: Download and Install latest version of Java 8 (JDK)
Step 1.2: Setup Java Environment Variables
Step 2: Android Installation and Setup
This is one of the most time consuming process, and the one which is prone to errors if not done properly. The below articles provide you with the step by step approach to download and setup the latest version of Android SDK manager. With the latest version of Android Studio, there are many changes in the way Android needs to be setup. So we recommend you to use the latest version of Android Studio, so that you can follow the steps accurately as provided in the below articles.
Step 2.1: Download and Install Android Studio
Step 2.2: Install additional Android SDK tools
Step 2.3: Setup Android Environment Variables
Step 3: Appium tool setup
With the prerequisites completed, this section covers the Appium related content. This mainly involves setting up the latest version of Appium, and setting up your mobile device for test automation.
Step 3.1: Download and Install Appium Desktop App
Step 3.2: Download and Install Eclipse IDE for Java
Step 3.3: Turn On USB Debugging on your Android Device
Step 3.4: Download Appium Jars for Eclipse
Step 3.5: Create new project in Eclipse for Appium
Step 3.6: Find appPackage and appActivity name of your app
Step 3.7: First Appium test script to launch app on Android Device
Step 3.8: Learn more about Appium Desktop Client
Step 4: Appium Inspector Tutorial
This section is a series of 4-5 articles and it would explain the process of inspecting elements in your mobile app in detail. You will learn about the different ways in which Appium identifies elements, and you would also see code snippets with detailed examples.
Step 4.1: Learn about the basics of UI Automator Viewer
Step 4.2 (a): Use UIAutomatorViewer to find/inspect elements
Step 4.2 (b): Use UiSelector to identify elements on Android Device
Step 4.3: More about UI Automator Viewer and current limitations with mobile automation
Step 4.4: Learn the basics of Appium Desktop Inspector
Step 4.5: Inspect mobile element using Appium Desktop Inspector
Step 5: Miscellaneous Topics
This section deals with multiple topics which are at somewhat advanced level but you would mostly be using it at some point or the other.
Step 5.1: Learn about different Appium scroll strategies
Mobile Browser Automation
Learn how to automate test scripts on your mobile browser using Appium.
Step 1: Setup Appium for Chrome browser automation
Step 2: First test script to launch Chrome browser on mobile device
Step 3: Identify Mobile Browser Elements with Appium – Part 1
Step 4: Identify Mobile Browser Elements with Appium
Install Appium Desktop:
Appium Studio is an Open source GUI app to install Appium Server. It comes bundled with all the pre-requisites to install and use Appium Server. It also has an Inspector to get basic information on your Apps. It comes with a Recorder to create boilerplate code to automate your mobile apps.
Step 1) Go to http://appium.io/ and click on Download Appium.
Step 2) For Windows, select the exe file and download. The file is around 162MB will take time to download based on your internet speed.
Learn Appium Training from the Expert Trainers to Advance Your Career
- Instructor-led Sessions
- Real-life Case Studies
Step 3) Click on the downloaded exe.
Step 4) On a Windows machine, there is no need to install Appium. It runs directly from the exe. Once you click the exe you will see the following image for few minutes.
For Mac, you need to install the dmg
Step 5) Next you will see the Server Start Window. It populates the default host and port option which you can change. It also mentions the version of Appium being used.
Step 6) On clicking the Start Server Button, a new server is launched on the specified host and port. Server log output is shown.
Step 7) Click New Session Window.
Step 8) You can enter the Desired Capabilities and start a session.
Similar to Selenium IDE record and playback tool, Appium has an ‘Inspector’ to record and Playback. It records and plays native application behavior by inspecting DOM and generates the test scripts in any desired language. However, currently, there is no support for Appium Inspector for Microsoft Windows. In Windows, it launches the Appium Server but fails to inspect elements. However, UIAutomator viewer can be used as an option for Inspecting elements.
Steps to start with Appium Inspector on Mac machine:-
Step 1) Download and start your Appium server with the default IP Address 0.0.0.0 and the port 4725.
- Select the source file or .app files from local to test.
- Check the ‘App Path’ Checkbox to enable ‘Choose’ button.
Step 2) Now, click on ‘Choose’ button will give the option to browse and select test file from the local drive.
Step 3) Start Simulator on Mac machine.
Step 4) Click ‘Launch’ button from a top right corner, which enables a blue color icon. Again, click on this blue color icon, it will open the Appium inspector and Simulator with a pre-selected application.
Step 5) Launching your Appium Inspector will show the element hierarchy in column-wise structure. Also, a user can apply actions using buttons like Tap, Swipe, etc.
Step 6) Click on ‘Stop’ button to stop recording.
Attach Android Emulator to Appium :
Step 1) Install Android SDK in your system.
Go to Control panel >> System and Security >> System and from the left panel click on ‘Advanced System Settings’. From ‘System Properties’ pop up, click on ‘Advanced’ tab and then click on “Environment Variables” button.
Join in Appium Certification Course with Global Recognised CertificationWeekday / Weekend BatchesSee Batch Details
Step 2) Now, from ‘Environment variables’ pop up, ‘double click on ‘Path’ and set ANDROID_HOME variable that point to your SDK directory. In the path append the whole SDK folder path.
Step 3) Start your Android emulator or any attach any Android device to your system (Make sure you have Android Debugging option enabled in your Android device. To check Debugging Option. Go to Device Settings >> Developer Options >> Check “Debugging Option”).
Step 4) Open Command Prompt and navigate to your Android SDK’s \platform-tools\ directory (E.g. D:\adt-bundle-windows-x86_64-20130514\sdk\platform-tools).
Step 5)Run ‘adb devices’ command. You can see your connected device listed in Command Prompt window. (In CMD write ‘>adb devices’- This command will list the connected emulator instances. E.g.: adb –s emulator-5554 install <Location of .apk file>)
Step 6) Run ‘adb start-server’ command. It will start ADB server that will be used by Appium to send commands to your Android device.
Step 7) Now, navigate to Appium directory in your system and start Appium by clicking an Appium.exe file.
Step 8) Do not alter the IP address or port number and click ‘Launch’ button. Your Appium console starts at 127.0.0.1:4723 as shown in below.
Step 9) Click on ‘Start’ button, Appium server started running on your system.
APPIUM Test Case for Native Android App(Calculator)
- Download ADT eclipse plugin or download ADT bundled separately here
- Open Eclipse and Create a new Project >> Package >> Class
- Import Selenium library and Testng inside that new project.
- Now Create a small test Program for ‘Calculator.app’ to sum two numbers.
Appium Server and Android Emulator from ‘AVD Manager’ and Click Run >> TestNG. Above program will run the ‘Calculator.app’ on selected emulator and Result displayed under Eclipse console using a TestNG framework.
Limitations using APPIUM
- Appium does not support testing of Android Version lower than 4.2
- Limited support for hybrid app testing. e.g.: not possible to test the switching action of application from the web app to native and vice-versa.
- No support to run Appium Inspector on Microsoft Windows.