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 are different and more complex than testing traditional desktop and web applications.

Pre-requisites for Mobile Automation Testing on Windows Machine:-
1. Eclipse should be installed
2. Android SDK and APIs for recent versions of Android (Steps to Setup Android SDK)
3. Selenium Web driver knowledge.
4. Java knowledge
5. Some basic Knowledge of Mobile.

Install and Uninstall Application using Command Prompt:

Install an App: – adb install full_path_of_apk adb install C:\Users\Keshav\Downloads\teamchat.apk
Uninstall an App: –adb uninstall package_name_of_apk  adb uninstall teamchat.apk

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.

In Desired Capabilities, We have to provide “BROWSER_NAME” (Only in case of we have to automate test cases of Mobile Web else in case of app automation we have to keep this section blank), “VERSION” Android version of your mobile device, “devicename” as ANDROID and “platformName” as ANDROID. Instead of all the above we have to provide package name and activity name of the application (Steps to find Activity Name & Package name of an Android apk)

File app = new File(appDir, “Teamchat.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.teamchat”);
cap.setCapability(“appActivity”, “com.teamchat.SplashActivity”);
cap.setCapability(“app”, “Teamchat.apk”);

Setup Mobile Device For Automation using Appium:
For setting up mobile devices, we have to verify that whether developer options enable or not.
USB Debugging is allowed or not.
For Real device, Android version must be 4.2 or above.

Step By Step Installation:-
STEP 1: – Install and setup “JAVA” Link
STEP 2: – Install and setup Android SDK Link
STEP 3: – Restart the system (strongly recommended)
STEP 4: – Setup Eclipse and Pin to Task Bar (Right Click on Eclipse.exe and set it to Pin to Taskbar)
STEP 5: – Launch Eclipse and create a new project
STEP 6: – Check android is installed on your system or not. Open command prompt & type adb on command prompt
STEP 7: – Check Connected Device adb devices
STEP 8: – Install Device PC Suite
STEP 9: – Enable Developer Option and allow USB Debugging
Step 10: – After completing all these steps, just type adb devices on command prompt
Step 11:- adb install D:\Mobile_Setup\apk\Teamchat.apk
It will install the application on the connected device with a Success message.
Step 12: – Download & Install Appium Link
Step 13: – Install Appium by clicking on Appium.exe & Launch Appium
Step 14: – 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 15: – Launch UI Automator (Available at D:\SDK\tools location)
It will help us to find out the mobile objects.

How UI Automator works:-
1. Connect the device.
2. Launch the desired app
3. Launch UI Automator(/SDK/tools/UI Automator)
4. Click on Green Colored Icon Below and move the cursor to the desired object and Select the Object Properties.

Step 16: Object locators: – We have prioritized the list of locators to be used when scripting. Id, Name, Link text, Partial Link text, Tag Name, class name, CSS, XPath
Step 17: How to get .apk file properties:- aapt.exe dump badging apk file path
Step 18: Required JAR or Maven Dependencies
Import Selenium Stand Alone Server Jar (selenium-server-standalone-2.53.0) and Java-client.Jar 3.3.0