Appium Testing For Native Apps

A Quick Tutorial on Appium Testing Tool for Mobile Automation Testing.

GeekyAnts
The NativeBase v2.0 Blog [ Deprecated ]
5 min readJul 16, 2019

--

The job of a Software Testing Professional is not an easy one. It is filled with challenges, which are equally demanding. Right now, the mobile app market is booming tremendously and quality testing in this area is important. What is more important is to find the right Automation Tool which works on all mobile platforms.

Appium is an open source test automation framework which supports native, hybrid and mobile web apps. It drives iOS, Android, and Windows apps using the WebDriver protocol. The major asset of Appium is that this can work on both Android and iOS. This article can be treated as a quick walkthrough and tutorial on using Appium for testing on mobile applications.

The prerequisites to use Appium are Appium Desktop, Eclipse and Java SDK. You also need to be familiar with Java.

Setting Up The Environment

First of all, download Android Studio, download JDK and JRE from Oracle JavaSE and install JDK , JRE, Android Studio from SDK (It will take time because of the size of the file). Next, you need Appium Desktop or you can use Brew as well for mac. Click here to download Java 8.

Double click the .exe and run the installer. Continue with all default options.
Once done with installation create Android virtual devices (AVD).

Set the ANDROID_HOME, JAVA_HOME.
$ nano ~/.bash_profile

It will open in text file.

bash_profile

We are done with installation, configurations and setting the relevant paths. It’s important to know the capabilities of Android and iOS to write Appium scripts for mobile Application. For that, basic knowledge of any of programming languages like Java, C# , Python, Ruby , PHP , Javascript even frameworks like Robot Framework are important.

Now, we start the Appium script for Mobile App in Android, First we have to install Apk in Android emulator or a real device. Check the ADB devices connected to your system and install Apk by using the command below:

$ ADB devices:
$ adb install and Path of that Apk

To know Android capabilities, App Package and Activity enter the below command in terminal :

$ adb shell
generic_x86:/ $ dumpsys window windows | grep -E 'mCurrentFocus

Download Eclipse and Run

Start Eclipse and create a new Java Project and Package and main Class. Here, we need to add libraries to the project in Eclipse. You can use this link to download Eclipse.

Once you install it, an eclipse IDE window will open for writing the script and it will look like this.

Creating java project > package > java class > You need to add All .Jar files of Appium Java. For that, you need to follow the below steps .

Right click on Project > Build path > Configure Build Path > Libraries > Add External JARs > Apply and Close.

Once done with your class creation, you can start writing Automation scripts for Android.

Next, download TestNG From Eclipse Marketplace.
For this, Go to Help→ Eclipse Marketplace

Writing The Code (Android)

Add all required capabilities as shown below in main Class:

After adding capabilities in main Class, we have to create another package and another class in the same project and write code for Login page.
Here I am using POM(Page Object Model) and TestNG Frameworks.

After completing the Login Page , we have to create another Class which extends the main class in POM.

This script will Run the Test cases of Login Page for the Android version of the app.

Writing The Code (iOS):

Add all required capabilities as shown below in main class:

Create another package and another class in same project and write code for Login page( POM(Page Object Model) , TestNG Frameworks).

Finally After completing the Login Page , create another Class which extends the main class in POM.
The script below will Run Test cases of Login Page in iOS.

Before we start running our Appium Test Script, we need to make sure that the Appium Server is Running.

Appium server Android 0.0.0.0:4723
Appium server iOS 0.0.0.0:4724

Check if Apk & IPA files have been installed on your device (Android and iOS respectively). Also check whether all the required set capabilities are correct.

We have to start Appium by providing Two different Host and Port values like:
"http://0.0.0.0:4723/wd/hub" for Android
“http://0.0.0.0:4724/wd/hub" for iOS

Check if the Apk has been installed in your Device (Android or iOS) and whether all the required set capabilities are correct.

If yes, run as TestNG and it launches the App, does the Login procedure and
gives Total test runs, skips, Failure Test Cases as results in the console.

Here is a quick video to demonstrate how everything should work.

I will explain more about this Test scripts and Frameworks Along with Selenium/Java is also one of the Automation Testing Tool which is used to test Web Applications in my upcoming posts.

I hope this post has helped you like it was intended to. Thank you for reading and do leave some 👏 if you liked this article.

Hey Geeks! I am Sukanya J ,QA Automation Engineer at GeekyAnts.
I experimenting with web and Mobile Apps, and develop Automation scripts with Appium/Java, Selenium/Java. I Feel Software Testing is just not a daily job but it’s a responsibility to make sure that all releases in the world are bug free and function as intended.
If you have questions, you can reach out to me anytime. I’d love to get in touch with you.

--

--