Tech Blog updated with solution for latest problems, I encountered with selenium and mobile testing.
I professionally specialize in Calabash IOS & Android, Robotium
echo progress-bar >> ~/.curlrc
execute command to install rvm with latest ruby: \curl -L https://get.rvm.io | bash -s stable --ruby
Add below line into ~/.bash_profile
#RVM [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"# This loads RVM into a shell session.
Check calabash installation calabash-ios console /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:777:in `report_activate_error': Could not find RubyGem json (>= 0) (Gem::LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:211:in `activate' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:246:in `activate' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:245:in `each' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:245:in `activate' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:1056:in `gem' from /usr/bin/calabash-ios:18
install this command and you may see below error sudo gem install json
unable to convert "\xCF" from ASCII-8BIT to UTF-8 for lib/json/ext/generator.bundle,
Step 1) cd /Library/Preferences
Step 2) sudo vi com.apple.dockfixup.plist
Step 3) Locate unwanted startup items and remove them , save the file and exit it and restart ur machine
I started making a website for one of my relative and had to refresh my memory on how to get it up and running.
Here is how simple way to do it
Ingredients needed :
1) Domain name
2) web hosting server
3) Some html page.
How to get them
1) I registered my domain at http://www.bigrock.in/, You can get a domain name at other popular sites like godaddy.com / net4.in
2) For web host server, I chose www.50webs.com/ which is my favorite free web hosting server for almost 5 years now.
Other options are using wordpress or blogger or some paid servers like hostgator
3) HTML code
open note pad , copy below code and save it as "index.html" <!DOCTYPE html> <html> <body> <h1>My First Heading</h1> <p>My first paragraph.</p> </body> </html>
Steps to do at Bigrock website
Login to ur domain provider (say you have purchased domain name hello.com)
click on your domain and choose website manager or similar options
update nameserver to point to your webhost in this case its dns1.50webs.com and dns2.50webs.com check pic4
Once you have set nameservers wait for an hour or so and check domain provider website again Check picture fig5 below, It indicates some warnings ignore them (these warnings are an indication that nameservers are recognized)
Mean proceed to next section where we upload files to web host
Pic4: Set name servers
Fig5: Ignore these errors
Steps for uploading files to webhost (50webs.com in this case)
Create login and log into 50webs.com
Go to domain manager -> my domains -> hosted domain -> host domain
Create a domain name exactly same as your website name (purchased with bigrock ex: hello.com). Having same name will help 50webs resolve DNS to your website for all incoming traffic that comes to your domain purchased at bigrock.
Copy the index.html file we saved previously in to file manager for the newly created domain in step3
Wait for 1-2 hours for DNS and NS to recognize ur website
In my case it took1 hour but it might take upto 24 hours for DNS to be working properly
Hope you website must be up & running soon
Drop a link to ur site when you have created using my blog
It makes me feel proud :)
This is an example to read excel file in ruby (this can be used for reading excel workbook as well) using RubyXL gem
Step 1) Create an excel workbook like below
Step 2) Create a ruby file including gems require 'rubygems' require 'rubyXL'
Copy path to excel file and replace it in place of work book workbook = RubyXL::Parser.parse("/Users/username/Downloads/simple_spreadsheet.xlsm")
This first sheet of excel workbook can be read into hash table using below command hash_arr=workbook[0].get_table(["Login", "email", "password"])
Multiple tables can be present in same file and they will read based on the format given in the above command (this helps in organizing many data tables in single sheet of excel file)
Step 3: If needed it can be used in cucumber file as below
This post is intended to explain how to reuse step definitions in calabash
Lets see with an example with a feature file
Scenario Outline: I am able to test macro Given I want to test macro Then I have macro "hello" Examples: | filename | | hello |
Step definitions file
Call the second step definition here Given(/^I want to test macro$/) do var="test string" macro 'I have macro "'+var+'"' end This step can be used as macro in other step definitions Then(/^I have macro "(.*?)"$/) do |arg1| puts arg1 end
1) Use query("webView css:'*'") to get all associated elements on page then search for text you are looking at. Index of results returned from query can be used to identify elements Example:
res=query("webView css:'*'") res[12] - could be the element you may want to verify
2) To verify if object is shown on screen .empty? can be very handy res=query("view text:'SomeText'").empty? # res is false if element is present use begin rescue block (in Ruby) to catch these exceptions and handle them
3) use regular expression
query("view {text LIKE '*hello*'} ")
4) Using variables in search
text_to_check="hello"
query("view {text LIKE '*#{text_to_check}*'} ") 5) Looping up and down until text found
This is a like a quick guide to help tester setup certificate and IOS project for calabash-ios
1) Create apple developer account
https://developer.apple.com/ then add your account to your company list for that you may need invitation from one of other team members who are already in that group
2) Go to https://developer.apple.com/devcenter/ios/index.action and log in with user name & pwd
Go to Certificates, Identifiers & Profiles
under Certificates, download certificate for ur name
Double click on and add it login key chain
3) Configuring IOS device
Connect device
Go to xcode -> window > organizer
select device -> click on add portal
Now you device must be all set to be used for current project
Error & Solution:
to use dev certificate that was present on old machine on new machine export p12 certificate from previous machine and then use it here
I had a test app for which i had to write tests but after each login, to logout I had to navigate 4-5 pages, This added extra overhead to my testing
Suppose i have 3 tests and second test fails without logging out I would never have starting point for my 3rd test and hence that would fail
I wanted a single start point from where I start my test each time. Thats when I decided to use calabash backdoor function.
Lets looks at changes first
1) Added below function delaration in app AppDelegate.m
This code will change for your application but the way of using it is similar.
In my case dev team member helped me with logout functionality
2) Add declaration in AppDelegate.h This can be kept as below or method name can be changed but method signature has to be maintained. //Calabash Method - (NSString *) calabashBackdoor:(NSString *)aIgnorable;
3) Now compile the Application
Time of verify changes are reflected or not
4) Deploy application , Launch calabash-ios console
run 'calabashBackdoor' command and this must be executed on the application
I did face this problem of getting ruby 1.9.3 on mac osx 10.7
Then I realized I need rvm but before doing all this I did need xcode installed
this must be easy for mac experts not for me definitely
Here are simple steps for a mac beginner to get ruby 1.9.3
Download install xcode from appstore
Install command line tools from xcode - Go to xcode->preferences->downloads->components->commandline tools
Install ruby using RVM - Install ruby 1.9.3 and use it rvm install 1.9.3 rvm use 1.9.3
Errors & Solution
If there are error in RVM installation do this Type following commands ~ $: source ~/.rvm/scripts/rvm ~ $: type rvm | head -n 1 rvm is a function ~ $: vi ~/.bash_profile add this line into bash_profile
"source ~/.rvm/scripts/rvm" Install ruby 1.9.3 and use it
there are list of ruby commands that can be used in calabash-android to get pciture from camera and save it
I had this problem running commands from calabash to take pciture, I was able to get past it using these 2 functions
def takePicFromCamera
system('adb shell input keyevent 27') # click take picture button end
# save picture by clicking on save def savePicture system('adb shell input keyevent 21') Page.new.waitFor(2) # waitfor 2 second system('adb shell input keyevent 22') # select save Page.new.waitFor(2) # waitfor 2 second system('adb shell input keyevent 23') # Click save Page.new.waitFor(5) # waitfor 5 second end
Robotium 4.0 has been released with webview support which enables testing of hybrid applications .
Some new functionalities have been added which enables testing of webpage embedded within native app also called as hybrid android application.
new functionalities inculde:
waitForWebElement(By by), clickOnWebElement(WebElement webElement),
enterTextInWebElement(By by, String text), typeTextInWebElement(By by,
String text), clearTextInWebElement(By by), getWebElement(By by, int
index)
This is not an exhaustive explanation for a starter but should suffice some one who knows a bit of robotium,
Please feel free to leave comments below
Steps
Part1: running webview application
Steps
1) Go to github copy project link - https://github.com/tejasv02/Androidwebviewsampleapp.git
2) Import project into eclipse
3) Solve dependency errors
4) Run web view application test as Android application
Part2: Testing webview application
Steps:
1) Go to github and copy project link - https://github.com/tejasv02/Robotium4Webviewtest.git
2) Import project into eclipse
3) Solve dependency errors
4) Run web view application test as Android application
Problems : The import android cannot be resolved
Install plugin for android - https://dl-ssl.google.com/android/eclipse/
set path for Android SDK - Windows -> preferences -> Android
Finally !!!
I did run calabash android to test mobile app with embedded webview using calabash
This tools covers all requirements necessary for mobile application testing project, there are some limitation as all functionalities are not implemented.
Certainly this is the best tool for mobile hybrid application testing (fonemonkey works fine but I am not very happy with that)
I have created a test project that can be downloaded and used to testing sample app, Just to make sure things are fine and installation is OK
Problems
1) when there is this below error
resign application using http://www.troido.de/re-sign.jar java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{sh.calaba.android.test/sh.calaba.instrumentationbac kend.CalabashInstrumentationTestRunner} from pid=549, uid=549 not allowed because package sh.calaba.android.test does not have a signature matching the target com.example.pickerviews2
2) When there are missing libraries search for them and add them to lib folder
Go to properties -> Java Build path -> libraries and remove Error libraries
3) Unable to resolve target 'android-7' PickerViews Unknown Android Target Problem
This means project.properties will have to be updated to android sdk level installed in SDK manager