Thursday, 16 May 2013


Calabash-Android:

Calabash-Android is a automation tool used to automate mobile application testing. Calabash-Android lets you run Cucumber features on your Android device or emulator.  Calabash enables you to write and execute automated acceptance tests of mobile apps. Calabash is cross-platform, supporting Android and iOS native apps. It is open source and free, and has a company, LessPainful, backing and developing it.

1.      First Create the Following Folder Structure:
"D:\CALABASH_ANDROID\Android-SDK"
"D:\CALABASH_ANDROID\Apache-Ant"
"D:\CALABASH_ANDROID\DevKit"
"D:\CALABASH_ANDROID\List-of-Gems"
"D:\CALABASH_ANDROID\Eclipse"
"D:\CALABASH_ANDROID\Ansicon"

2.       Download RUBY 1.9.3 and install it.

3.  Download Android SDK, extract the same and Place it into “D:\CALABASH_ANDROID\Android-SDK” and set the environment path for “ANDROID_HOME” in Environment Variables. For e.g. Variable as ANDROID_HOME and Value as D:\CALABASH_ANDROID\adt-bundle-windows-x64-20130219\sdk

4.      Download Java SDK 1.7, and Install, Then set the environment path for “JAVA_HOME” in Environment Variables. For e.g. Variable as JAVA_HOME and Value as C:\Users\SV0068675\Program Files\Java\jdk1.7.0_21

5.    Download APACHE ANT and Extract the file in to D:\CALABASH_ ANDROID \Apache-Ant, Then set the environment path for “ANT_HOME” in Environment Variables. For e.g. Variable as ANT_HOME and Value as D:\ CALABASH_ANDROID\apache-ant-1.8.4

6.       Now Add the “C:\Ruby193\bin; %JAVA_HOME%\bin; D:\CALABASH_ANDROID\Apache-Ant\bin; D:\CALABASH_ANDROID\adt-bundle-windows-x64-20130219\sdk\platforms;D:\ CALABASH_ANDROID\adt-bundle-windows-x64-20130219\sdk\platform-tools” in the System PATH Variable.

7.       Download and extract the Development Kit in “D:\CALABASH_ANDROID\DevKit” folder. Then in CMD type D: and enter, then Type D:\CALABASH_ANDROID\DevKit and Enter Then Type ruby dk.rb init and Enter Then Type ruby dk.rb install and Enter.

8.       Copy and paste the list of gems needed for Calabash in “D:\CALABASH_ANDROID\List-of-Gems” folder. i.e. awesome_print (1.1.0), bigdecimal (1.1.0), builder (3.0.0), calabash-android (0.4.4, 0.3.1), cucumber (1.3.1), diff-lcs (1.1.3), gherkin (2.12.0 x86-mingw32, 2.11.1 x86-mingw32), io-console (0.3), json (1.5.4), minitest (2.5.1), multi_json (1.7.2), retriable (1.3.3), rubyzip (0.9.9), slowhandcuke (0.0.3).

9.       In CMD Type CD D: then Type D:\CALABASH_ANDROID\List-of-Gems and Type gem install builder bigdecimal diff-lcs multi_json json gherkin io-console minitest retriable rubyzip slowhandcuke cucumber calabash-android or you can install separately also like gem install builder after installed, install next one as gem install bigdecimal.

10.   Open a New CMD window and check all the installed items.
For RUBY => Type ruby –version it should print like ruby 1.9.3p392 (2013-02-22) [i386-mingw32]
For Java JDK => Type Java –version it should print like java version "1.7.0_21"
For Ant => Type ant –version it should print like Apache Ant(TM) version 1.8.4 compiled on May 22 2012
For Android SDK => Type adb version it should print like Android Debug Bridge version 1.0.31
For List of Gems => Type gem list it should print All Installed Gems

NOTE: The Environment Variable Path may vary according to your configuration.

11.   Download the APK (http://goo.gl/FqVIw) and Feature file (http://goo.gl/tUh7R) from the links.
*Feature contains the steps to execute
       12. Place the APK and Feature file in your Android SDK’s “Platform-tools” folder.
       13. Open the CMD and Navigate into the Android SDK’s “Platform-tools” folder.
Connect android device or start Emulator where the test needs to be run.
14. Then Type calabash-android resign ‘Path to the APK file’\ ApplicationName.apk, it won’t display any message until any errors.

15. Then Type calabash-android build ‘Path to the APK file’\ ApplicationName.apk,
 It will display the below message “Done signing the test server. Moved it to test_servers/036c487b477982871415b9165d6046e5_0.4.4.apk”

e.g. D:\CALABASH_ANDROID\Android-SDK\android-sdk\platform-tools>calabash-android build D:\CALABASH_ANDROID\Android-SDK\android-sdk\platform-tools\APKFiles\CalabashAndroidDemo.apk
Done signing the test server. Moved it to test_servers/036c487b477982871415b9165d6046e5_0.4.4.apk

16. Then Type calabash-android run ‘Path to the APK file’\ ApplicationName.apk, then it will start run the app and it will display like

Feature: Login
  Scenario: Wrong UserName Login                    # features\my_first.feature:3
608 KB/s (528579 bytes in 0.848s)
257 KB/s (90860 bytes in 0.345s)
Given my app is running                         # calabash-android-0.4.4/lib/calabash-android/steps/app_steps.rb:6
 And I wait for "Welcome to Android!!" to appear # calabash-android-0.4.4/lib/calabash-android/steps/progress_steps.rb:27
 Then I enter "name" as "username"               # calabash-android-0.4.4/lib/calabash-android/steps/enter_text_steps.rb:1
 And I enter "password" as "password"            # calabash-android-0.4.4/lib/calabash-android/steps/enter_text_steps.rb:1
 Then I press "Login"                            # calabash-android-0.4.4/lib/calabash-android/steps/press_button_steps.rb:17
 And I wait for "Unknown username" to appear     # calabash-android-0.4.4/lib/calabash-android/steps/progress_steps.rb:27
 Then take picture                               # calabash-android-0.4.4/lib/calabash-android/steps/screenshot_steps.rb:1

Scenario: Wrong Password Login                    # features\my_first.feature:15
 Given my app is running                         # calabash-android-0.4.4/lib/calabash-android/steps/app_steps.rb:6
 And I wait for "Welcome to Android!!" to appear # calabash-android-0.4.4/lib/calabash-android/steps/progress_steps.rb:27
 Then I enter "Username" as "username"           # calabash-android-0.4.4/lib/calabash-android/steps/enter_text_steps.rb:1
 And I enter "word" as "password"                # calabash-android-0.4.4/lib/calabash-android/steps/enter_text_steps.rb:1
 Then I press "Login"                            # calabash-android-0.4.4/lib/calabash-android/steps/press_button_steps.rb:17
 And I wait for "Wrong password" to appear       # calabash-android-0.4.4/lib/calabash-android/steps/progress_steps.rb:27
 Then take picture                               # calabash-android-0.4.4/lib/calabash-android/steps/screenshot_steps.rb:1

Scenario: Login to the app                              # features\my_first.feature:27
 Given my app is running                               # calabash-android-0.4.4/lib/calabash-android/steps/app_steps.rb:6
 And I wait for "Welcome to Android!!" to appear       # calabash-android-0.4.4/lib/calabash-android/steps/progress_steps.rb:27
 Then I enter "Username" as "username"                 # calabash-android-0.4.4/lib/calabash-android/steps/enter_text_steps.rb:1
 And I enter "password" as "password"                  # calabash-android-0.4.4/lib/calabash-android/steps/enter_text_steps.rb:1
 Then take picture                                     # calabash-android-0.4.4/lib/calabash-android/steps/screenshot_steps.rb:1
 Then I press "Login"                                  # calabash-android-0.4.4/lib/calabash-android/steps/press_button_steps.rb:17
 And I wait for "Enter Your Particulars" to appear     # calabash-android-0.4.4/lib/calabash-android/steps/progress_steps.rb:27
 Then I enter "Sivakumar" as "Name"                    # calabash-android-0.4.4/lib/calabash-android/steps/enter_text_steps.rb:1
 Then I enter "68675" as "EmpID"                       # calabash-android-0.4.4/lib/calabash-android/steps/enter_text_steps.rb:1
 And I enter "TechM" as "Company"                      # calabash-android-0.4.4/lib/calabash-android/steps/enter_text_steps.rb:1
 Then take picture                                     # calabash-android-0.4.4/lib/calabash-android/steps/screenshot_steps.rb:1
 Then I press "Save"                                   # calabash-android-0.4.4/lib/calabash-android/steps/press_button_steps.rb:17
 And I wait for "Details saved successfully" to appear # calabash-android-0.4.4/lib/calabash-android/steps/progress_steps.rb:27
 Then take picture                                     # calabash-android-0.4.4/lib/calabash-android/steps/screenshot_steps.rb:1
3 scenarios (3 passed)
28 steps (28 passed)
0m59.065s

During the Test run, screen shot which is taken by the tool will be stored at the location, “D:\CALABASH_ANDROID\Android-SDK\android-sdk\platform-tools”

17.  We need to modify the .feature file according to our test.





1 comment:

  1. No test server found for this combination of app and calabash version. Recreatin
    g test server.
    Done signing the test server. Moved it to test_servers/37686a3b323aaf661e73ea4ff
    fb7c280_0.4.21.apk
    C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.4.21/lib/calabash-android
    /helpers.rb:18:in `main_activity': 'launchable-activity' not found in aapt outpu
    t (RuntimeError)
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.4.21/bin/cal
    abash-android-run.rb:19:in `calabash_run'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.4.21/bin/cal
    abash-android:71:in `'
    from C:/Ruby193/bin/calabash-android:23:in `load'
    from C:/Ruby193/bin/calabash-android:23:in `'


    I ecountered an above error while running the 16th step from above set up process...please tell me the solution .Thanks in advance

    ReplyDelete