Calabash Android - A complete guide [closed]

2019-06-12 11:47发布

I am new to Calabash - Android. I set up the environment. I would be really grateful if an expert in this arena , who is thorough with the whole concept, could help me with this. I found many IDEs like Eclipse, IntelliJ and editors like Sublime, TextWrangler, etc. I am confused about which one to choose for an ideal Android developer. I am familiar with Ruby, but not an expert. Should I improve my knowledge on Ruby ? Also, if anyone can help me by providing some URLs, I would be really grateful to you. I found many questions on Stackoverflow itself, but I couldn't find anything which is a complete guide for a novice like me. I hope somebody can help me

1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-06-12 12:18

A GUIDE FOR CALABASH-ANDROID

You need not be a Ruby expert for writing functional test cases or working with QA for adding new test scenarios. An Android developer can comfortably work, checkout Calabash-Android from github (https://github.com/calabash/calabash-android) & add it to your IDE. Try to understand how step definitions written in the framework, you can write Ruby step definition for your project in the same way it is written in the framework. Also, you can use canned steps ( but not recommended ). I am explaining here the steps which I followed & explored for implementing functional tests using Calabash - Android.

Prerequisite I assume, You have setup Calabash environment, Android SDK, Java, Ruby etc ( all the stuff required to run Android application & Calabash ). I am using Genymotion as I found it is the fastest emulator. You need to select one IDE for Ruby & Cucumber. As I am using Android Studio, I prefer to use IntelliJ. So, I am using RubyMine

Be comfortable with Calabash Console & make sure everything works fine & try on console first.

Calabash Console
Prerequisite Make sure your Genymotion emulator is running

  • For referring apk easily, export it ( In Mac or Ubuntu ) export APK=your_application.apk

  • Resign apk calabash-android resign $APK (Make sure you are using the same keystone certificate(signature) for resigning)

  • Open Calabash console calabash-android console $APK

  • Start test server No test server found for this combination of app and calabash version. Recreating test server. Done signing the test server. Moved it to test_servers/24433decbe6bdd96b13b9b58258231a8_0.4.20.apk irb(main):001:0> start_test_server_in_background

For returning back to IRB parent method (Calabash console): irb(main):012:1> end Reference URL : http://www.ruby-doc.org/stdlib-2.0/libdoc/irb/rdoc/IRB.html

For your reference, I am adding some of the popular queries I tried:

irb(main):017:0> acceptBtn = query("Button marked:'Accept'")
touch(acceptBtn)
query("relativelayout")
query("homeimagebutton")
logOn = query("homeimagebutton id:'home_log_on'")
touch(logOn)
element_exists("* hint:'Search by address, city or zip'")
wait_for_elements_exist( ["* hint:'Search by address, city or zip'"], :timeout => 2)
wait_for_elements_exist( ["* text:'Log On'"], :timeout => 2)

While using IRB: Cntrl + D : use this to get prompt if a wrong command is typed For Eg. if you type irb(main):002:0> query("*) irb(main):003:1" for going back to prompt, do Cntrl + D Now you get prompt like irb(main):003:1> here type 'end' as below: irb(main):003:1> end Now it shows syntax error & get it to the prompt as below: SyntaxError: (irb):2: unterminated string meets end of file (irb):2: syntax error, unexpected end-of-input, expecting ')' from /.rvm/rubies/ruby-2.1.1/bin/irb:11:in `' irb(main):004:0>

Searching for a text in the Screen: text = query('android.view.View','text') text = text.to_s text.include?'test message'

Some of the useful URLs are:
[http://developer.xamarin.com/guides/testcloud/calabash/] [http://referenceforu.blogspot.com/2013/08/calabash-android-tutorial.html] [http://blog.lesspainful.com/2012/03/07/Calabash/]
For understanding how to use IRB For easy upgrading of Ruby [http://rvm.io/]
For understanding how to setup for multiple applications: [http://blog.lesspainful.com/2013/03/15/Testing-Multiple-Android-Apps/]

查看更多
登录 后发表回答