Introduction to Calabash

Mastering the leading techniques of mobile app testing is a part of my daily work and I got a strong desire to know everything about mobile app testing automation. So, I decided to investigate the Calabash framework.

What is Calabash?

By its nature, Calabash is a driver which runs the application on device. In this case, I use the bunch of Calabash and Cucumber.

At the top of the article, you can see an image which depicks the architecture of Calabash. The interaction with application occurs through performing the user actions. Taking into account the specifics of mobile applications, this can be gestures, touches, as well as checks for presence of text, buttons and many other things.

To work with the Query request, we use Calabash console. For example, we have a step where we want to specify pressing on the "Archive" button. To do this, we find out which object has text "Archive" by writing in the command line: irb (main): 008: 0> query ("* text: 'Archive'"). As a result, we get to know that the object with the text "Settings" has id "menuSettings". Now we can press the button with corresponding ID.

Search of objects may be considered as one of the greatest disadvantages of the test automation with Calabash. When the interface changes, many locators will stop working and searching for them is quite difficult.

For writing tests, you may use predefined steps that come with Calabash (see Canned steps on GitHub) unless it is sufficient, use Ruby Api:

Given/^IamontheWelcomeScreen$/doelement_exists("view")sleep(STEP_PAUSE)endAnd(/^Ishouldsee"([^"]*)" on the screen$/) do |expected_mark|wait_for(WAIT_TIMEOUT){view_with_mark_exists(expected_mark)}sleep(STEP_PAUSE)endThen(/^Ienter"([^"]*)" in the "([^"]*)"field$/)do|text_to_type,field_name|touch("UITextFieldLabel marked:'#{field_name}'")wait_for_keyboard()keyboard_enter_texttext_to_typesleep(STEP_PAUSE)endThen/^I(?:touch|press)(?:done|search)$/dodonesleep(STEP_PAUSE)endThen(/^Ilogoutfromapplication$/)dotouch("UIButton marked:'Sign out'")sleep(STEP_PAUSE)end

Conclusion

All the above leads to the conclusion that the Calabash framework is very helpful for testing automation of mobile applications and can be successfully used even by the beginners.