Calabash is open source, cross-platform automation tool, supporting
Android and iOS based native application.
Ruby Installation:
download ruby version greater than 1.8.7 and less than 2.0 from link “http://rubyinstaller.org/downloads/”.
Install downloaded ruby setup file into your machine.
Android SDK: download
and install android sdk from link: “http://developer.android.com/sdk/index.html”
for more details how to setup and install Android SDK visit link “http://developer.android.com/sdk/installing/index.html”.
Click link "more detail" how to create android virtual device.
Calabash-Android Installation:
open command prompt and run below command:
gem install calabash-android
Generate cucumber
skeleton folder-structure: calabash-android automatic generate cucumber
skeleton folder-structure when you run command:
Calabash-android gen
Below are folder structure generated by running above command:
features
-------- step_definitions
------------------------- calabash_steps.rb
-------- support
---------------- app_installation_hooks.rb
---------------- app_life_cycle_hooks.rb
---------------- env.rb
---------------- hooks.rb
-------- my_first.feature
Resign Android
application: run below command to resign your android application with default android keystroke
Calabash-android resign $APPNAME
Note: Open
android emulator before performing below action.
Steps Find App element
locator detail: run below command to install test server and android app to install on your emulator.
open calabash console by running below command:
Calabash-android run $APPNAME
open calabash console by running below command:
Calabash-android console $APPNAME
Start calabash test server by running command
start_test_server_in_background
For getting element locators detail of app, we use query ()
command of calabash. It is very important and powerful command; we can fetch
element locator by using below approaches.
Run “query(“button”) command on calabash-android
opened console you can get details of all button.
By this way you can fetch element details of android
application and can use this element into your scripts.
Note: query ()
command fetch element detail only opened page on emulator.
How to run Test
Run command into default generated folder or your automation
project to execute cucumber calabash test.
Calabash-android run $APPNAME
Hi,
ReplyDeleteThank you for this blog. I am stuck with this error:
irb(main):002:0> start_test_server_in_background
RuntimeError: App did not start
`block in start_test_server_in_background'
I tried extracting the AndroidManifest.xml file and I do see that it has the line
Am I supposed to keep this manifest file in any path? Please help
Thank you
Jo
Hi jo
ReplyDeleteplease make sure INTERNET permission is setup in your android application or not.
Thanks for this nice post.
ReplyDeleteDo you have any idea how to run test scenario parallel in more than two devices ?
Hi Istiyak ,
DeleteHave you done parallel tests execution??
If yes could you please post how to do that???
Thanks in advance,
we are getting following error when run calabash-android resign app
ReplyDeleteD:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.4.14/lib/calabash-android
/java_keystore.rb:11:in `initialize': Could not list certificates in keystore. P
robably because the password was incorrect. (RuntimeError)
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.4.14/lib/cal
abash-android/java_keystore.rb:46:in `new'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.4.14/lib/cal
abash-android/java_keystore.rb:46:in `read_keystore_with_default_password_and_al
ias'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.4.14/lib/cal
abash-android/java_keystore.rb:65:in `get_keystores'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.4.14/lib/cal
abash-android/helpers.rb:88:in `sign_apk'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.4.14/lib/cal
abash-android/helpers.rb:83:in `block in resign_apk'
from D:/Ruby193/lib/ruby/1.9.1/tmpdir.rb:83:in `mktmpdir'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.4.14/lib/cal
abash-android/helpers.rb:76:in `resign_apk'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.4.14/bin/cal
abash-android:106:in `'
from D:/Ruby193/bin/calabash-android:23:in `load'
from D:/Ruby193/bin/calabash-android:23:in `'
I resign and build android app using calabash-android but when I run test with calabash-android run command getting below error:
ReplyDeleteScenario: As a valid user I can log into my app # features\my_first.feature:3
516 KB/s (553714 bytes in 1.047s)
113 KB/s (2083080 bytes in 17.896s)
App did not start (RuntimeError)
C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.4.14/lib/calabash-andro
id/operations.rb:505:in `block in start_test_server_in_background'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/retriable-1.3.3.1/lib/retriable/retriable.
rb:31:in `perform'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/retriable-1.3.3.1/lib/retriable/retriable.
rb:53:in `retriable'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.4.14/lib/calabash-andro
id/operations.rb:504:in `start_test_server_in_background'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.4.14/lib/calabash-andro
Please provide me solution?
Update your calabash-android, and resign, build and run again your test...
DeleteHi,
ReplyDeleteThe article is very good!! As your guidance I have done all the configuration and it is working fine for my Demo application developed using Native android. And it is returning two buttons.
irb(main):003:0> query("button")
[
[0] {
"id" => "help_btn",
"enabled" => true,
"contentDescription" => "help",
"class" => "android.widget.Button",
"text" => "?",
"rect" => {
"center_y" => 173.0,
"center_x" => 420.0,
"height" => 54,
"y" => 146,
"width" => 30,
"x" => 405
},
"description" => "android.widget.Button{40cfd200 VFED..C. ......I. 360,12-390,66 #7f07000c app:id/help_btn}"
},
[1] {
"id" => "login_btn",
"enabled" => true,
"contentDescription" => nil,
"class" => "android.widget.Button",
"text" => "LOGIN",
"rect" => {
"center_y" => 429.0,
"center_x" => 345.0,
"height" => 72,
"y" => 393,
"width" => 180,
"x" => 255
},
"description" => "android.widget.Button{40d04358 VFED..C. ......I. 255,259-435,331 #7f070010 app:id/login_btn}"
}
]
irb(main):004:0>
---------------
But it is not recognizing the controls of my another application. The application is Hybrid and developed into PhoneGap. When I ran the query for button, it is returning nothing:
irb(main):002:0> query("button")
[]
irb(main):003:0>
Please guide me to test my application developed into Phonegap. Is there any additional setting need to be done for PhoneGap??
Any help would be appreciated.
Facing same issue:
ReplyDeleteirb(main):002:0> query("button")
[]
irb(main):003:0>