This document provides instructions for setting up Appium on Windows to test Android apps. It involves installing prerequisites like Java, Android SDK, Eclipse plugins. Then configuring Appium by launching the inspector, specifying Android and general settings like server address. Next it covers connecting an Android device in USB debugging mode, verifying the connection, and using UI Automator Viewer to inspect app elements. It also explains how to get the app package name and activity using APKInfo. Finally it describes setting up an Eclipse project for Appium, adding required jars, and running a sample test script providing device and app capabilities.
1. Appium Setup & Configuration on Windows
Pre-requisites:
1. Appium Client App
2. Java Development Kit (JDK)
3. Android SDK
4. Eclipse ADT plugin
5. Make sure the above list of apps/softwares is installed on PC
Setup Steps:
1. Install Appium client app
2. Follow the instruction to complete the installation process.
3. Configure Appium:
Launch Appium inspector first.
Android Settings -
b. Click on Android Settings button at the top left corner
c. Select Platform Name = Android
d. Select Automation Name = Appium
e. Select PlatformVersion = Your Android device’s OS version
General Settings -
a. Click on General Settings button besides Android Settings button.
b. Keep the server address & port number noted, we will need it while scripting.
c. Server Address: 127.0.0.1
d. Port Number: 4723
4. Connect Android device with PC in USB debugging mode to run Appium test.
(I hope everyone knows how to enable the USB debugging option in an Android
device. Let me know if anyone don’t.)
5. Verify the device is connected properlywith the PC using ADB server
Run a command “adb devices”
It will show connected device name.
6. Locating Android App Elements Using UI Automator Viewer.
a. Run uiautomator.bat file from the folder tools under sdk bundle
b. Open any installed application from your device, say Calculator App
c. In UI Automator Viewer, click on Device Screenshot image button at the top right
corner.
d. It will process to capture the device screenshot.(After capturing the screenshot, it
will show the Calculator app’s UI in UI Automator Viewer on left pane)
e. On left pane, it will show the Calculator app’s UI element’s hierarchy view & the
property of each element.
f. Select the elements whichever you want to locate & find the Xpath of respective
element using the properties shown on right pane.
2. 7. Find the .APK file package name & launcher activity name by using APKInfo
application.
a. Install APKInfo application from Google Store.
b. Launch the APKInfo app, it will show you installed applications list.
c. Scroll down to Calculator app & now tap & hold it.
d. Select the Detailed Information option
e. Here it will show the details & you can find the app package name & app activity
name.
8. Configure project in Eclipse for Appium.
a. Create New project in Eclipse.
- Start Eclipse
- Set Workspace
- Create new project in Eclipse with some package name, say Android
- Install TestNG
b. Download latest Jars of WebDriver & Appium Client Libraries from here
c. Add Jar files in Project’s build path
9. Running first test script using Eclipse.
a. Gather required capabilities first.
- Find Android device name, say “ZX1B32FFXF”
(You will get it by using command “adb devices” in command prompt)
- Find Android Software App Package Name, say “com.android.calculator2”
(You will get it using APKInfo app)
- Find App Activity Name, say “com.android.calculator2.calculator”
(You will get it using APKInfo app)
- Find Android OS version, say 4.4.4
(Settings > About Device > Android Version)
b. Launch & Start Appium Node server.
- Launch Appium (Server Address: 127.0.0.1 & Port Number: 4723)
- Start Appium Node Server (Click on Start button at right top)
c. Create Appium Test Script in Eclipse
Pre-requisites -
deviceName - Name of device displayed using adb devices command
CapabilityType.VERSION - OS version of your device
appPackage - App’s package name
appActivity - App’s activity name
d. Running Appium Test Script
- Select Run As > TestNG from option
- View your Android phone screen