How to Setup Calabash for Android

Calabash Android Setup

How to Setup Calabash for Android ?

Calabash-android is a great little test automation tool for functional testing of Android applications that use the simple English test script creation of Cucumber to automate your application. It lets you automate testing with little or no coding.
Here is what you need to get started with calabash-android.

Install Android, Ruby, Cucumber and Calabash

  1. Install the android-sdk to run the emulator.
  2. Install Ruby on your system.
  3. Run the command “gem install cucumber” in cmd to install Cucumber on your system. After successful extraction check its version and update if necessary.
  4. Run the command “gem install calabash-android” in cmd to install calabash-android on your system.

Configure your System

  1. Set the Android path to the following in system variables:
    ANDROID_HOME=C:Program FilesAndroidandroid-sdk
  2. Set the JAVA_Home path to the following in system variables:
    JAVA_HOME=C:/Program Files/Java/jdk1.7.0_17
  3. Set the ANT_HOME path to the following in system variables:
  4. Set the path to the following in system variables:

Open your cmd and Install the Mobile Application

  1. Navigate to platform-tools directory.
  2. Copy and paste your application inside this directory.
  3. Open the android-avd manager and create a new emulator.
  4. Start your emulator and wait till it completely loads.
  5. Open cmd and navigate to platform-tools. In cmd enter the following command:
    >adb install your_file_name.apk
  6.  After your app is installed, verify that it is present in menu screen of your emulator.

Create a New Directory

  1. Create a new directory using the following command:
    > mkdir D:FirstProject
  2. Now generate the folder structure with feature file, step-definitions, support and lib using the following command:
    D:FirstProject> calabash-android gen
  3. Now sign your apk using its keystore path, password and alias:
    D:FirstProject> calabash-android setup

    Be sure to note the complete path to debug.keystore. When you are asked to enter the keystore location, enter the full path including the name: i.e D:Calabashkeystore_name.
    The system will ask for debug.keystore of the application, the password and the alias to sign your apk. .calabash-settings file. The folder structure will be created upon completion.

  4. Now write following code in your feature file-> my_first:
    Feature: General functionality for InfantAudit

    Scenario: Create New Store

    Given I am on the Splash Screen

    Then I press the “Log in” button
  5. Write the following code in step definitions:
    $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib'unless $LOAD_PATH.include?(File.dirname(__FILE__) + '/../../lib')
    require 'calabash-android/calabash_steps'
    require 'utilities.rb'
    Given /^I am on the Splash Screen$/ do
        wait_for(180) {element_exists("button id:'btnLogin'")}
  6. Open cmd and run your code using following command:
    D:FirstProject> calabash-android run your_file_name.apk
  7. If you will be automating the next sprint of this application then you have to re-build and re-sign application to create a new test server for each sprint using following command:
    D:FirstProject> calabash-android build your_file_name.apk
    D:FirstProject> calabash-android resign your_file_name.apk

No Test Server Error

You sometimes get the following error while running apk through calabash which you can resolve using the method described below.

No test server found for this combination of app and calabash version. Recreating test server. /Library/Ruby/Gems/1.8/gems/calabash-android-0.4.3.pre4/lib/calabash-android/helpers.rb:148:in `extract_md5_fingerprint’: No MD5 fingerprint found: (RuntimeError)

Recommended Solution

  1. Copy your “Calabash” folder having “feature” file.
  2. Paste it into your android workspace having gen, res, src folder.
  3. Navigate to new path and again run apk file.
  4. Now, Test server will create inside your calabash folder.

Alternate Solution:

  1. Re-sign your apk file using command:
    -D:FirstProject> calabash-android build your_file_name.apk
  2. Build your apk file using command:
    D:FirstProject> calabash-android resign your_file_name.apk

Comments 0

Your email address will not be published. Required fields are marked *

You may also like

More From: Automation Testing