Google+ Followers

Wednesday, 19 November 2014

Android Phone : how to proxy network requests using charles (explained with screenshots)



Precondition:
Have a wifi network on which PC( MAC) and Mobile phone are connected
record IP address of PC and Mobile
PC: 192.168.1.104
Mobile: 192.168.1.XX



Steps:

Performed on Mobile:

  1. Open Settings
  2. Selected the network connected
  3. Press long tap and choose modify network
  4. Select show advanced options 
  5. Select Manual
  6. Enter the IP address of the machine running 192.168.1.104 and port as 8888 
  7. Press SAVE 
  8. go to browser (chrome) and open a website "timesofindia.com"


PC


  1. Download charles from here and launch it,http://www.charlesproxy.com/download/
  2.  (now perform step 11 in mobile) Charles shows a dialog requesting to allow incoming connections
  3. Once the connections are allowed, any request made to internet from mobile will appear in charles, use the filter to refine the request (as shown in image below


Tuesday, 28 October 2014

command line command to list all IOS simulators installed on my mac

Open Terminal and run the below command
xcrun instruments -s devices

expected output:
Known Devices:
LON02759 (com.apple.instruments.devices.local)
iPhone - Simulator - iOS 7.1
iPhone Retina (3.5-inch) - Simulator - iOS 7.1
iPhone Retina (4-inch) - Simulator - iOS 7.1
iPhone Retina (4-inch 64-bit) - Simulator - iOS 7.1
iPad - Simulator - iOS 7.1
iPad Retina - Simulator - iOS 7.1
iPad Retina (64-bit) - Simulator - iOS 7.1

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'