Home » Software Testing » Initial setup required for Mobile native app automation with Calabash

Initial setup required for Mobile native app automation with Calabash

In this post i am trying to elaborate the overall setup for the ATDD approach along with the Calabash-Cucumber with Ruby as a language.
Calabash is very popular, mostly used in all of big giants organisation now a days & its defined as an automated testing technology for Android and IOS native and hybrid applications.It provides you to run cross-platform, supporting Android and iOS native apps. Calabash consists of two libraries calabash-android and calabash-ios. As you can imagine, calabash-android is the automation and testing library for Android, and similarly calabash-ios is for iOS.

=>Need the Xcode 6.1.1(latest version available on appstore) installed on the Mac machine on which you are going to run your test.
=>Need to install the command line tools from the prefrences pane under “Downloads” in Xcode.
-=>If multiple Xcode is install on machine need to switch the latest version by  :-

=>Now, Install the Ruby , You will find its already installed on MAC machine, You can check by
ruby -v , Morover, if you have multiple version of ruby, try to install with the help of rvm & set default ruby in the machine whichever you want.

=>Installation of the gems needed for your project: This can be done in two ways, First you have option to install manually by running multiple installation of gem commands on machine, but for future reference if neeed to setup the same project on other slave machines, its better to use second approach ie:- Use Gemfile to install the gem(for using this you must in need of manual installation of bundler by :- gem install bundler).
Here are the gems needed to setup calabash:-

Note you may need to run sudo gem install calabash-cucumber if you see ERROR: While executing gem … (Gem::FilePermissionError)).

=>To use Calabash for iOS in your app, you must do two things: link with our framework: calabash.framework, and install a ruby gem as described below. You also need to link with Apple’s CFNetwork framework if you are not already using this.

=>For functional testing with Calabash iOS, you should create a whole separate target by duplicating your production target in Xcode.Calabash iOS consists of two parts: a client library written in Ruby, and calabash.framework, a server framework written in Objective-C (a Clojure/JVM version of the client is coming too). To use calabash you make a special test target in XCode that links with calabash.framework. The application is otherwise unchanged. The server framework will start an HTTP server inside your app that listens for requests from the client library.

PS: Calabash interacts with the UI elements in your app via accessibility labels. That’s how it knows which button to tap when you issue a command like Then I touch "reply". As the author of the feature file, you can determine the labels of the various UI elements using the niftyAccessibility Inspector in the iOS Simulator. To turn it on, follow these steps:

  1. Run your app in the iOS Simulator via Xcode
  2. Stop the app
  3. Swipe from left to right to go to the first screen
  4. Tap on Settings
  5. Tap on General
  6. Tap on Accessibility
  7. Turn the Accessibility Inspector toggle ON

Here is the example of one feature file (Login.feature) which we are going to run:-

The above feature file describes the acceptance criteria for the login feature which is already we have in Login.feature. The cucumber tool executes your feature files which contain steps that are defined either in predefined or custom(user defined) steps definitions. Custom steps are written using the API that the client library exposes. The API methods make HTTP requests to the server, which does things like finding components in the UI and taking actions on them. Here is an illustration:


This generated a features skeleton dir for your tests:

Running your Login.feature test now with the cucumber seems like(if app bundle path is in your location) :-

Now try running the feature my_first.feature with cucumber.

If all went well, You will see the Simulator run with the app, If your app path is somewhere else, You can pass APP_BUNDLE_PATH=/location/of/app/ along with the cucumber command.

NOTE:- For writing step definitions ,Please refer to the coming posts………



1 thought on “Initial setup required for Mobile native app automation with Calabash”

  1. Pingback: Testing Bits – 12/14/14 – 12/20/14 | Testing Curator Blog

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top
Scroll to Top