Working with Calabash

Hi All,

Now we know how to install and run Calabash and its all requirements and prerequisites.

Now let’s see how to work with it.

Open the “calabash-android-0.9.0” folder. It resides at path C:\Ruby23\lib\ruby\gems\2.3.0\gems\calabash-android-0.9.0. The folder names will change in synch with the ruby/ calabash version you install on your machine.

Open the feature skeleton folder. Look out for this basic framework.

  • The *.feature file contains scenarios that we are going to automate.
  • The method used by the feature file is written in *.rb file inside “step_definitions” folder.
  • Common methods, environment setup, app installation and hooks should be placed inside “support” folder.

Resign & Build the app

  • Calabash-android resign *.apk
  • Calabash-android build *.apk

Attach the device to the system /Open the emulator

Check device attached. Type command >>adb devices

Attached devices list should be displayed.

How to Find the Element Locator

  • Open the console. Type the Command.>>calabash android console “APK Path”>>start_test_server_in_background
  • Above command launch the app on the device. To find the element locator use following command.>query “*”

Creating New Scripts

Open the feature file and following lines

Feature: Login feature
 Scenario: As a valid user I can log into my app
 When I press "Login"
 And I enter my username 
 And I enter my password
 Then I see "Welcome to coolest app ever"

Open the Step Definition file & Define the method into *.rb file.

Given /^I am on the login windows$/ do
 wait_for(:timeout =>100) { element_exists("* id:'loginInput;")}
 check_element_exists("* id:'loginInput;")
end.
Now you can automate your UI testing using the Calabash.