Installing Appium with Ruby bindings – moving from Calabash – Part 3

Building an IOS app for Appium

For those coming across from calabash, you will be used to having to create a duplicate -cal scheme to embed the calabash.framework into your app. Well, thankfully with Appium there is no need to do this at all. Simply open your Xcode project and build the app. That’s it – nothing special required.

Benefit of Appium over Calabash

The major benefit of Appium here is that the app that you are testing is exactly the same app as you release into production – there is no linked automation framework. This is a definite advantage over calabash.

Running Appium

All you need to do now is open 2 tabs terminal tabs.

In the first one run :

node .

Once this has started up, in the second tab run:


You now have a fully functioning Appium environment.

Important note: I strongly advise that  you use bundler with gemfiles if you plan to have appium with ruby bindings installed on the same machine as calabash. If you don’t you can end up with horrible things happening.

If you are experiencing gem issues I whole heartedly recommend this post  Installing ruby the Correct Way by cbednarski. It also has a great Appendix on cleaning your environment before re-installing your gems.

Launching Selenium Webdriver from within a Calabash automation script

Many people ask if it’s possible to launch a browser from within a Calabash automation script. Well, since the selenium-webdriver is just another gem the answer is of course yes, it is entirely possible.

Before I explain how to do this, you might first want to consider whether you really should do this. If you are trying to test a mobile app and a website in one automation suite – then this isn’t a good idea  – they should probably have separate automation suites. If you are trying to inject data through something like a CMS for your app then you should probably be using the API. However, if you really feel the need to do this then the solution is simple.

  1. Add the selenium-webdriver gem to your bundle install
  2. Create a helper module – lets called it BrowserHelper
  3. In that helper module require the selenium webdriver
  4. Create some classes / methods in your BrowserHelper module as required
  5. Call the methods from your calabash script – i.e. BrowserHelper::ClassName.method_name()

You are now interacting the with browser using Selenium Webdriver.

Calabash run_loop fifo error – Swift app not launching in Simulator solution

For the past day or so I’ve been having a problem with calabash where I couldn’t get calabash to launch an ios app in the simulator without encountering a run_loop error saying :


Turns out that this is was due to the push notification alert popping up before Instruments had taken control of the simulator. This issue is a known calabash issue – see here.

ios calabash fifo error


The solution was a two step approach:

  1. Add a delay to the code to prevent the alert popping up too soon. The app was written in SWIFT. I added the delay code to AppDelegate.swift as follows:

//Existing code

        if application.respondsToSelector(“registerUserNotificationSettings:”) {

                    //Newly add code to delay the pop up.

            let time = dispatch_time(dispatch_time_t(DISPATCH_TIME_NOW), 4 * Int64(NSEC_PER_SEC))

            dispatch_after(time, dispatch_get_main_queue()) {

                //Code to be executed with delay

            let settings = UIUserNotificationSettings(forTypes: [UIUserNotificationType.Alert,UIUserNotificationType.Badge,

UIUserNotificationType.Sound], categories: nil)





  2. Add code to my calabash script to accept the alert:

if uia_query(:alert).count > 0
# dismiss by touching ‘OK’
uia_tap_mark ‘OK

uia_tap_mark ‘OK’

Sublime Text 2 with Cucumber and Gherkin formatting

I normally use RubyMine for my calabash automation code but it’s pretty memory intensive so I thought I’d try something a bit more lightweight (and free)..I choose Sublime Text 2 and installed the cucumber-sublime bundle from drewada on Github.

It works a treat – the only annoying this is that when you hit tab it always tries to autocomplete – this is particularly annoying when creating tables in your feature files.

The cucumber sublime bundle does everything that you’d expect to do i.e. it makes both feature files and step files easy to read; it prompts existing steps and autocompletes variables etc.

Note: it’s also a nifty ruby editor, bash editor and YAML editor. I find myself only opening up RubyMine now when I need to debug something or do something like find other usages of methods etc.

Here’s a little screen shot of how it formats a Gherkin in a Feature file:


Installing Appium with Ruby bindings – moving from Calabash – Part 2

In part 1 we looked at the set up of Appium when moving from Calabash. In the next articles we look at getting the ruby console (ARC) working to query your app, but first we have to generate an appium.txt file. This article will help you resolve the annoying App doesn’t exist error message relating to appium.txt when running the arc command.

Create the appium.txt file

The next step is to create the appium.txt file – simple right? Well when I first tried to this i hit a couple of problems.

The appium.txt tells appium what platform you are automating and what simulator you wish to use  and where your app is (amongst other things). Although it is nicely explained in the Appium tutuorial it fails to point out three things

  1.   You can create a sample empty appium.txt using the command
 arc setup ios

2.   Not everyone likes using nano to create files but if you use TextEdit to create / edit the appium.txt file you will end up with the wrong kind of double quotes and later on when you come to run the ARC (ruby console) you’ll get appium.txt errors. If this happens copy the correct double quoted from the file generated by the arc setup ios command.

3. When adding the path to you app, appium will automatically prefix it with the path to the folder where are running the arc command from i.e. it is a relative path, not an absolute path. if you use the absolute path to your app you will get an error something like this:

 App doesn't exist

My appium.txt looks like this – you can use it as an example:

platformName = "ios"
platformVersion = "9.0"
deviceName ="iPhone 5s"
app = "./"
autoAcceptAlerts = "true"
waitForAppScript = "true"

sauce_username = ""
sauce_access_key = ""

I’ll explain the autoAcceptAlerts and waitForAppScript values in another article – running the Appium Ruby Console (arc).

In the next article i’ll explain the difference between building an app for calabash and building an app for Appium.

Installing Appium with Ruby bindings – moving from Calabash – Part 1

If you read my blog you will know that my test automation tool of choice for mobile applications is Calabash using Ruby. However there is definitely a shift in the market towards Appium as the preferred tool of choice for mobile app testing and towards Java as the preferred language of choice for a Software Developer In Test (SDET).

Until now I have avoided Appium as my initial results with it a couple of years ago showed it to be “buggy” and somewhat unreliable – for example a test would execute successfully 9 times and then fail on the 10th attempt for no known reason…but maybe it’s time to give it a go again.

This post shows what I needed to do to get Appium with Ruby Bindings set up and running on my mac

 To Install Appium with Ruby Bindings

  1. Install the appium console
gem install --no-rdoc --no-ri appium_console

2.  Install the flaky gem (f you don’t already have it)

gem install --no-rdoc --no-ri flaky

3.  Do  a brew update (I’m assuming here that you already have brew installed, if not take a look at the calabash set up post to see how to install homebrew

brew update

[Note – if you get a HOMEBREW_CORE_FORMULA_REGEX error here – just run brew update again (it’s a known brew issue)

4. Upgrade nodesj as follows

brew upgrade node

5. Install grunt

npm install -g grunt grunt-cli

6. I am assuming that you have ant and maven already installed – you may want to upgrade them.

7. Clone the appium git repo

git clone git://

8. Ensure you have an Xcode version greater than 4.6.3 installed. See this post for a quick way to check your version of Xcode from the command line:

9. cd into your appium folder (from the repo clone that you did in step 7 and execute


Note – I encountered a problem here – i had the following output:

* Configuring Android bootstrap
---- FAILURE: exited with status 1 ----

Please see the following post on how to resolve this issue:

10. Finally run:

 grunt authorize

11. You are then ready to launch Appium by running:

node .

You will then see a message like this:

info: Welcome to Appium v1.4.13 (REV 96cfaef4aafa2693b4f0630b9d44ca7f0f6ed369)

In the next article I look at running the ruby console to query your app.

Appium install failure – exited with status 1


When trying to complete the install of Appium by running


I was seeing an error which said exited with status 1

I re-ran the script for ios only and it completed successfully…see below:

 ./ --ios
---- completed successfully ----

I then tried running the script for android only and turned on verbose logging – it failed as follows:

 ./ --android --verbose

Error: Target id is not valid. Use 'android list targets' to get the target ids.
Warning: Setup cmd /Users/user/Android/sdk/tools/android failed with code 1 Use --force to continue.


This error occurred because the script has a hard coded reference to the Android SDK Level 19 API and I didn’t have that version of the API installed.
To rectify this I installed the SDK 19 API and then re-ran the script for android. It completed successfully..see below:

 ./ --android --verbose

---- completed successfully ----

Find your Xcode version using Terminal

To quickly find what version of Xcode you are using from the command line (Terminal) just type:

xcodebuild -version

you’ll get output which looks something like this:

Xcode 6.4
Build version 6E35b

Test automation language poll