Google+ Followers

Wednesday, 30 April 2014

Calabash IOS / Android most used commands


Commands to check id's of all elements present in view
query("view,:id") for IOS 
query("*,:id") for android


Commands to list description of all elements 
query("view,:description") for IOS 
query("*,:description") for android

Sunday, 27 April 2014

Ruby subtract unix times and convert it into days and format DateTime

require 'date'
res=Time.now
days=2
res2=Time.now+(days*24*60*60)
DateTime.strptime(Time.now.utc.to_i.to_s,'%s').strftime("%d %m %y")
#find difference between 2 date times
((res2-res)/(24*60*60)).to_i

calabash ruby: Installing ruby rvm on mac OSX why and how

Why Ruby or RVM ?
Calabash commands needs ruby to be installed for interpreting commands to actions.


Which version of ruby to install ? - 
Check here pre requisites section in this link 
https://github.com/calabash/calabash-ios
Currently its 2.0+

Why Rvm ?  -  RVM is used to manage to rubies on mac 

Alternative to RVM ?  -  use rbenv 

How to install rvm ?
run these command from terminal on mac

$ \curl -sSL https://get.rvm.io | bash -s stable --ruby
(there is a backslash before curl. This prevents misbehaving if you have aliased it with configuration in your ~/.curlrc file)
Then install required version of ruby ..
$ rvm install 2.0.0
$ rvm use 2.0.0
You can set a version of Ruby to use as the default for new shells. Note that this overrides the ‘system’ ruby
$ rvm use 2.1.0 --default

Check here for more documentation - http://gauravsohoni.wordpress.com/2014/01/01/rvm-implode-and-rvm-install/
      • When to clean and install - Check errors section below
      • How to verify RVM installation is successful

      Close existing terminal and reopen new terminal window
      a) type this command in terminal 'open ~/.bash_profile' check if you see code the this 


      #RVM


      [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

      b) type this command 'rvm list'
      check ouput it must be like below

      ~ $: rvm list

      rvm rubies
         ruby-2.0.0-p353 [ x86_64 ]
      =* ruby-2.0.0-p451 [ x86_64 ]

      # => - current

      # =* - current && default
      #  * - default

      c) Ruby version currently used 

      ~ $: ruby -v


      ruby 2.0.0p451 


      Common Issues: While installing calabash gems 
        1) Error during RVM installation
        About to install Homebrew, press `Enter` for default installation in `/usr/local`,
        type new path if you wish custom Homebrew installation (the path needs to be writable for user)
        : Requirements installation failed with status: 1.



        2) ERROR:  While executing gem ... (Gem::FilePermissionError)
            You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
        lon04-04266:~ dakojuu$ sudo gem install calabash-cucumber
        Building native extensions.  This could take a while...
        ERROR:  Error installing calabash-cucumber:
        ERROR: Failed to build gem native extension.

            /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
        checking for main() in -lc... yes
        creating Makefile
          Solution resintall RVM


          Thursday, 17 April 2014

          Android -adb fast and easy way to get screenshots


          • Connect android device to PC / Mac ( make sure android sdk path is set)
          • run below commands, screen shot of current screen is taken and save on to current folder from where this command is run
          adb shell screencap -p /sdcard/screen.png
          sleep 0.1
          adb pull /sdcard/screen.png

          Sunday, 13 April 2014

          Command to launch ios simulator from mac command line OSX

          Use the below command


          alias sl='open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app'

            Adding alias to bash profile
            Open Bash profile ( ~/.bash_profile)
            and add the below line  
            alias sl='open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app'

            2 Solutions: How to find APP_BUNDLE_PATH calabash ios automation

            Solution 1:
            Open Xcode preferences and select location where .app file (generated when IOS code is compiled will be located) should be placed.

            APP_BUNDLE_PATH calabash ios automation

            Solution 2:
            Open Xcode
            Open organizer (or just press 'Command+ Shift +2')
            Find the application for which you are locating .app file (picture below)


            Thursday, 10 April 2014

            calabash IOS & Android FAQ


            1. What are the installation procedure for calabash iOS in windows? 
            No
            I would say not to try calabash ios with windows.
            Even if you want use windows for calabash ios options are limited.


            2. How to avoid install / uninstall the app every-time for android (while running scripts)?
             For android
            Comment this code in app_installation_hooks.rb file in android support folder 
               uninstall_apps
               install_app(ENV["TEST_APP_PATH"])
               install_app(ENV["APP_PATH"])

            3. How to run multiple feature file in one run command?
            Use cucumber tags on features - https://github.com/cucumber/cucumber/wiki/Tags