Mobile App Automation Testing Using Appium

21 / Oct / 2015 by Keshav Kashyap 0 comments

What is Mobile Automation Testing?

Mobile Automated testing provides a mechanism to consistently repeat a test procedure and verify application results. It can be effective both for regression testing as well during development. Testing mobile applications is different and more complex than testing traditional desktop and web applications.

Prerequisites for Mobile Automation Testing on Windows 7:-

  • Eclipse should be installed
  • Android SDK and APIs for recent versions of Android
  • Selenium Web driver knowledge.
  • Java should be installed on system and Mobile device must be connected to the system
  • Java knowledge
  • Some basic Knowledge of Mobile.

Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device.

Install and Un-install Application using CMD:-

Install an App: –

                   adb install full_path_of_apk  

                   adb install C:\Users\TTND\Downloads\teamchat.apk

Un-Install an App: –

                    adb uninstall package_name_of_apk

                    adb uninstall com. teamchat

What is Appium?

  • Appium is an Open source , Cross Platform test automation tool for mobile apps
  • Supports automation of Native , Hybrid and Mobile Web apps
  • Based on Client-Server Architecture
  • Appium Server written in Node.js

What are Desired Capabilities?

Desired Capabilities are a set of keys and values sent to the Appium server to tell the server what kind of automation session we’re interested in starting up.

File appDir=new File(“E:\\Softwares\\APK\\News”);

File app = new File(appDir, “SplashActivity_2.1.22_latlong.apk”);

DesiredCapabilities cap=new DesiredCapabilities();

cap.setCapability(“BROWSER_NAME”, “”);

cap.setCapability(“VERSION”, “4.4.4”);

cap.setCapability(“devicename”, “ANDROID”);

cap.setCapability(“platformName”, “ANDROID”);

cap.setCapability(“appPackage”, “com.shopclues”);

cap.setCapability(“appActivity”, “com.shopclues.SplashActivity”);

cap.setCapability(“app”, “SplashActivity_2.1.22_latlong.apk”);

Setup Mobile Device For Automation using Appium:-

  • For setting up mobile devices, we have to verify that whether developer options is enable or not.
  • USB Debugging is allowed or not.
  • For Real device, Android version must be2 or above.

Step By Step Installation:-

STEP 1:- Install and Setup JAVA

STEP 2:- Install Android SDK. By default it will be installed in C:\Program Files\Android. You have to just copy the folder and paste it to some other drive. E.g.:- D:\SDK

STEP 3:- Now setup ANDROID_HOME

                                   D:\SDK

STEP 4:-Setup Tools and Platform Tools Path in User Variable

                                  D:\SDK\platform-tools;D:\SDK\tools;

STEP 5:- Restart the system (Strongly Recommended)

STEP 6:- Setup Eclipse and Pin to Task Bar (Right Click on Eclipse.exe and set it to Pin to Taskbar)

STEP 7:- Launch Eclipse and create a new project

STEP 8:- Check android is install on your system or not. Open cmd –> type adb on cmd prompt

STEP 9:- Check Connected Device adb devices

STEP 10:- Install Device PC Suite

STEP 11:- Enable Developer Option and allow USB Debugging

Step 12:- After completing all these steps, just type adb devices on cmd prompt

Step 13:- adb install D:\Mobile_Setup\apk\ ShopClues.apk

It will install the application on the connected device with Success message.

Step 14:- Download Appium https://bitbucket.org/appium/appium.app/downloads/

Step 15:- Install Appium and click on Appium.exe

Step 16:- Launch Appium

Step 17: – Setup is complete and now we have to start the Mobile Automation:-

  • Attach your Mobile Device with your system using adb devices command and verify that device is attached to the system.
  • Start Eclipse and create a new program for mobile device automation.
  • Launch Appium.
  • After launching Appium Run the Script.

Step 18: – Launch UI Automator (Available at D:\SDK\tools location) It will help us to find out the mobile objects.

How to find objects on mobile app:-

  • Connect the device.
  • Launch the desired app
  • Launch UI Automator(/SDK/tools/UI Automator)
  • Click on Green Colored Icon Below and move the cursor to desired object and Select the Object Properties.

Step 19:- Object locators:-

We have prioritized the list of locators to be used when scripting.
Id, Name, Linktext, Partial Linktext, Tag Name, class name, Css, xpath

Step 20: – How to get .apk file properties:- aapt.exe dump badging apk file path

Step 21:- Required JAR’s

Import Selenium Stand Alone Server Jar (selenium-server-standalone-2.47.0) and Java-client.Jar 3.1.0

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *