Learning Mobile Automation With Appium in 2020
In this blog we will learn about mobile automation with Appium, Appium mobile testing, what is Appium framework, and Appium tools. So let’s get started!!
Mobile automation with Appium
APPIUM is a freely circulated open-source mobile application UI testing framework. It allows hybrid, native, and web application testing and aids automation tests on physical devices. Mobile automation with Appium proposes cross-platform application testing, i.e. one API works for both Android and iOS platform test scripts.
It has no dependency on the Mobile device OS because Appium has a framework that translates Selenium Webdriver commands into UIAutomation (iOS) or UIAutomator (Android) commands relying on the device type, not any OS type.
How Appium Works?
- Appium is written using a Node.js platform though it is an ‘HTTP Server’. It drives iOS and an Android session utilizing the Webdriver JSON wire protocol. Therefore, 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 uncovers a REST API.
- It obtains connection and command requests from the client and enforces that command on mobile devices (Android / iOS).
- It replies back with HTTP responses. Also, to implement this request, it uses the mobile testing Appium automation frameworks to lead the user interface of the apps.
Apple Instruments for iOS, instruments that are accessible only in Xcode 3.0 or later with OS X v10.5 and later Google UIAutomator for Android API level 16 or bigger
Prerequisite to use Appium
- Install ANDROID SDK
- 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, though it is not required as whenever the Appium server is installed, by default it comes with “Node.exe” & NPM. It’s involved in the Current version of Appium.
- Install Appium Desktop
Installing Appium on your computer
It appears bundled with all the prerequisites to install and use the Server of Appium. It also has an Inspector to get fundamental data on your Apps. It comes with a Recorder to build a boilerplate code to automate your mobile apps.
Here are the steps to follow:
Step 1– To download Appium, go to http://appium.io/ and click on it.
Step 2– For Windows, select the exe file and download it. The file is approximately 162MB and it will take time to download based on the speed of your Internet.
Step 3– Click on the downloaded exe.
Step 4– On a Windows machine, there is no requirement to install Appium. It operates instantly from the exe. On the other hand, for Mac, you need to install the dmg
Step 5– In the next step you will see the Server Start Window. It occupies the default host and port option which you can alter. It also indicates the version of the Appium that’s being utilized.
Step 6- A new server is launched on the specified host and port, on clicking the Start Server button. The server log outcome is shown.
Step 7– Click on the New Session Window.
Step 8– You can enter the Desired Capabilities and begin a session.
The Appium inspector is similar to the Selenium IDE record and playback tool. It has an ‘Inspector’ to Record and Playback. It records and plays native application manners by inspecting DOM and develops the test scripts in any desired language. However, presently there is no support for Appium Inspector for Microsoft Windows. In Windows, it launches the Appium Server but fails to inspect components. However, the UIAutomator viewer can be used as an alternative for Inspecting elements.
Here are some steps to begin with Appium Inspector on Mac machine:-
Step 1- You can download and begin your Appium server with the default IP Address 0.0.0.0 and the port 4725.
Choose the source file or .app files from local to test.
Check the ‘App Path’ Checkbox to allow the ‘Choose’ button.
Step 2– Now, clicking on the ‘Choose’ button will give the option to browse and select the test file from the local drive.
Step 3– Start Simulator on Mac machine.
Step 4– Click the ‘Launch’ button from the top right corner, which facilitates a blue color icon. Furthermore, 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 indicate the element hierarchy in the column-wise structure. Furthermore, a user can apply actions using buttons like Tap, Swipe, etc.
Step 6– You can click on the ‘Stop’ button to stop the recording.
Limitations of using Appium
- Appium does not aid testing of Android Version lower than 4.2
- Limited support for hybrid app testing. For example, it is impossible to test the switching action of an application from the web app to native and vice-versa.
- There is no support to run Appium Inspector on Microsoft Windows
- Some familiar encountered errors and troubleshooting steps in Appium
1st error– The following desired capabilities are required, but were not provided like device Name, platform name
2nd. error- If you could not find adb. You should set the ANDROID_HOME environment variable with the Android SDK root directory path
3rd error- org.openqa.selenium.SessionNotCreatedException: A new session could not be created.
4th– How to find a DOM component or XPath in a mobile application?
1. You can add desired capabilities: device Name, platformName in APPIUM script. For example,: capabilities.setCapability (“deviceName”,”Emulator”); capabilities.setCapability (“platformName”,”Android”);
2. You perhaps need to set up SDK root directory path in system ‘Environment Variables’ in the ‘Path’ column
3. You are required to set a correct App path and restart the Appium server
4. Use ‘UIAutomatorviewer’ to find out DOM elements for Android applications
With developing trends and an ever-increasing need for Mobile Apps, all major businesses are migrating to get their business on mobile apps. Therefore to disclose quality mobile apps, mobile automation with appium of mobile apps is the modern trend in the industry. As discussed above we have learned everything about mobile automation with appium.
Appium tools is one of the leaders and most widely used all over the globe because of its simplicity and ease of use. It is used for automation testing of mobile apps for iOS or Android both.