Tuesday, March 31, 2015

Appium for Mobile Application Test Automation

Recently I came across an opensource mobile testing framework named Appium. The great thing about appium is that it works for native iOS, Android or even hybrid mobile web apps. I tested out Appium for iOS and below is a quick guide to the setup process. The appium documentation is a bit scattered so I thought it better to note down the process I followed here,

Step 1:

Install Appium application on mac by downloading the dmg from http://appium.io/. You can also run Appium from the source code if you like.


Step 2:

Launch the installed Appium application and run the 'doctor' (the icon with a stethoscope) to verify all pre-requisites for Appium are installed and setup already. If you see any errors in the doctor console, first fix them. In my case I needed to set the ANDROID_HOME path before the doctor gave me full approval.

Step 3:

Setup Appium settings to run iOS tests. In order to be able to this you need to have Xcode and Command Line tools installed on your mac. In the iOS settings (the dialog launched when you click on the Apple icon), set the 'App Path' and the 'Bundle Id' for the app you want to test. Also make sure that the Xcode path is set. All the other settings are optional. Note that for the 'App Path' you should give the path to the debug version of the .app file of your app, so that it can be run on the simulator. On OSX Maverick the path to this file can be found in the following location ~/Library/Developer/Xcode/DerivedData/.

Step 4:

Write your Appium test. I used the Appium Java API to write my test. I based my test on an example test provided by Appium ( https://github.com/appium/sample-code/blob/master/sample-code/examples/java/junit/src/test/java/com/saucelabs/appium/SimpleTest.java ). Note that you can use the Appium Inspector to determine the xpaths of elements in your application. Given below is the code I wrote to execute a login test.


Step 5:

Now you can run your test. Make sure you launch Appium first by clicking on the Launch button of Appium. The junit test you write requires Appium to be running in order to execute.


Wednesday, March 25, 2015

Hosting multiple Cordova plugins in the same git repository

The norm for hosting custom cordova plugins is one plugin per git repository. However there are instances when you would want to host multiple custom plugins inside the same repository. The cordova command for adding such plugins into a cordova project is as given below :

cordova plugin add [GIT_REPO_URL]#[BRANCH_NAME]:[FOLDER_PATH]

example :

cordova plugins add https://harinis@bitbucket.org/harinis/gtnexuscordovaplugins.git#master:attachmentHandler


Note that the FOLDER_PATH should point to the main plugin folder that contains the plugin.xml file.