giovedì 20 marzo 2014

Setup mobile test automation environment with open source Selenium and Appium tools

Today I want to start another topic this time related to mobile. How to setup an environment to write test automation code to test a mobile app. In particular the tecnnology regards Selenium and Appium open source tools. In a few words Selenium API allow you through the webdriver to interact directly with the browser, but with Appium the interaction can be extended to the mobile apps (android). Appium acts like a bridge between Selenium and device forwarding operations from code to the device app. Since Appium uses the Selenium JSON Wire Protocol, you can write your tests in any language supported by Selenium.

This post is only to setup environment for android case and selenium for java.


On the Desktop:
 
1. Download an eclipse environment (i.e. JUNO SR2):
http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/junosr2
 
2. Download and install JDK 1.7
 
3. Download Android Developer Tools (ADT) SDK
 http://developer.android.com/sdk/index.html
Unzip for example under c:\ADT and set the system variables to paths like in this example below:
 
ANDROID_HOME=c:\ADT\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_17
Path=c:\ADT\sdk\platform-tools;c:\ADT\sdk\tools;c:\ADT\sdk;c:\ADT\sdk\build-tools\19.0.3
 
4. Open the Android SDK Manager (i.e. c:\ADT\sdk\tools\android.bat)
 
5. Update the SDK packages to latest version like in the example below:
 
6. Downloand Selenium and include jars into your java project: 

7. Download Appium:

Unzip it in a dir (i.e: c:\Appium_0.16.0)
 
8. Download and install .NET5 (this is a prerequisite to start Appium program, to get the .NET5 download you can just run Appium.exe it popups the link)
 
Additional Steps for Samsung devices:
- Optionally update Android device to the latest firmware. For example to update a Samsung S3 to Android 4.3 use the official software "Kies": http://www.samsung.com/in/support/usefulsoftware/KIES/JSP
 

On the android device:

 
1. Enable developer mode on devices (on samsung: Tap 7 times on Settings --> About --> build number). Check this useful article for other android version:
 
2. Connect Android Developer Bridge to the real device, run this below:
 
> cd C:\ADT\sdk\platform-tools\
> adb devices
The command show for example this output:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
32309519ca3020f5        device
 
3. Run C:\Appium_0.16.0\Appium.exe program as Administrator:
- Config "App Path" to your APK
- Launch button (this starts the local server on port 4723 to interact with the device) and the console start logging:
 

       
4. Start Juno eclipse and run your java selenium code to test the APK.    

Once you run the java selenium program the APK is instrumented and built by Appium and then installed on device side. Note: if you installed the APK on device before this process you need to remove it, because of the existing conflict between instrumented and not instrumented version.
Then running the java selenium program the automatic installation is performed, the app is opened and all user operations specified in the code are executed automatically on the device.


1 commento:

  1. Great tips, many thanks for sharing. I have printed and will stick on the wall! I like this blog. IOS Developer

    RispondiElimina