Standav is now a Brillio company. Read More

Calabash-android testing framework

Calabash-android testing framework

Calabash facilitates to write and execute automated acceptance tests of mobile apps across the platforms – Android and iOS . Calabash, in essence, is a bridge to allow Cucumber framework to run tests on iOS and Android devices. The libraries of Calabash enable the test code to run in native and hybrid apps. The significant aspect of Cucumber is its ability to support Behaviour Driven Development (BDD). The scenarios of the test cases are written in typical English grammar of Gherkin language. The key words – Given, When, and Then are handy to describe the scenario.

I have discussed here how to run a simple test case using calabash on Android Apps.

Prerequisites :

  • System with windows OS
  • Java/jdk
  • Android sdk
  • Ruby (above 2.0)
  • Calabash-cucumber
  • Calabash-android (0.6)
  • APK file on which you are going to perform tests

Calabash- architecture


The clients can be, any of the Calabash clients. The Calabash server receives commands from the client in HTTP protocol and executes in the respective mobile/devices/emulator.

Installations in windows

• Download and Install java [I have installed 1.7], set the java home path
      Download java from here
      Verify it using command–   java -version
• Download Install android sdk, set android home in the environment variables
       Download android sdk from here
       Verify it using command–  adb devices
• Download and install ruby
       Download ruby from here
       Verify it using command–  ruby –v (it will show the version)

• Install Calabash-android

       Command to install :

gem install calabash-android

The above command will install the latest version.(I encountered issues with the latest 0.7.1.So I installed 0.6.0)
      Calabash android internally installs cucumber also
      Verify cucumber installation using command cucumber –version
      (If cucumber not found install it using command gem install calabash-cucumber)
      Verify calabash installation using command calabash-android version

I created  a simple test case; the steps to be followed are as below:

• Create a folder and give a name say “Sample“
• Open command prompt and go to sample folder (ex: cd ..\Projects\Sample)
• Run–  calabash-android gen
– It will create the cucumber structure in current directory
• Resign app:

calabash-android resign  …..\Projects\APK\sample.apk

• Build the app:

calabash-android build ……\Projects\APK\sample.apk

Identifying elements of the app on the device

calabash-android console  …\APK\sample.apk

Now we can query for elements and their attributes

Ex1: query(“*”) // it will get all elements in the current screen
Ex2: query(“SystemWebView css=‘buttons’”) // it will get all buttons in the current view [If the app is hybrid and it is written using cordova, we should use SystemWebView]

We can also use UIAutomatorviewer to identify elements [UIAutomater comes along with android sdk]

Feature file (.feature)

• By default feature file will come as shown below :


Edit this file according to your scenarios.

Element identification sample query on hybrid web view :

Query: query(“SystemWebView css:’button'”) : It will get all web view buttons in current page as shown in the screen shot below.


Step definition file (.rb)
• The calabash_steps.rb file looks as below: 


Run the feature file:

Calabash-android run  …\Projects\APK\sample.apk


Passed all 7 steps of a scenario


This is very impressive USER ACCEPTANCE testing methodology as the Behavior Driven Development  of the application,  very well depicts to all the stakeholders how the application is  meeting their expectations.

Leave a Reply