Google+ Followers

Monday, 2 March 2015

Expect script to compile Titanium project and add calabash framework to it using ticalabash

Expect script is bit advanced version of shell script
Where terminal can wait for the result of the previous command and execute the next query based on the output of the previous result.
Take a look at this amazing blog for expect script examples - http://www.thegeekstuff.com/2010/10/expect-examples/

TiCalabash is a package which can be used to add calabash to Titanium project and execute tests. - https://github.com/appersonlabs/TiCalabash


Below shell script does the following sequence of steps 

  1. Cleans Project
  2. Builds project
  3. Adds calabash-ios framework to code and creates -cal scheme
  4. compile the project with calabash framework added



#!/usr/bin/expect
#!/bin/sh

set arg1 [lindex $argv 0]

set timeout 20
spawn ti clean
expect {
    "Project cleaned successfully" { puts "STEP 1 DONE" }
    timeout { puts "failed to find text"; exit 1 }
}


if { $arg1 == "phone" } {
 spawn ti build -p ios -b;
 puts "expect.exp - Phone build"
} elseif { $arg1 == "tablet" } {
 spawn ti build -p ios -Y ipad -b --retina;
 puts "expect.exp - Tablet build"
}

set timeout 400
expect {
    "Initiating Xcode pre-compile" { puts "STEP 2 DONE" }
    timeout { puts "*** FAILED TO FIND - Initiating Xcode pre-compile "; exit 1 }
}

expect {
    "Project built successfully" { puts "STEP 3 DONE" }
    timeout { puts "*** FAILED TO FIND - Project built successfully "; exit 1 }
}

set timeout 20
spawn ti calabash —platform=iphone
expect "Please answer yes (y) or no (n)"  { send "n\r" }

set timeout 200
expect {
    "Default target:" { send "\r" }
    timeout { puts "failed to find text"; exit 1 }
}

expect {
    "Setup done" { puts "STEP 4 DONE" }
 timeout { puts "failed to find text: Setup done"; exit 1}
}


expect {
 "** BUILD SUCCEEDED **" {}
 timeout { puts "failed to find text"; exit 1 }
}

Disable VKB(Virtual Key Board) on android genymotion emulator

Steps to Disable keyboard in Genymotion

1) start Genymotion emulator
2) Go to settings
3) Select language and Input
4) Open Current keyboard under Keyboard and Input methods
5) Disable hardware option


Checkout the Animated GIF below 

Friday, 23 January 2015

Useful calabash queries : methods to count elements / read elements and find text present


















These are queries used with UI picker view - https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIPickerView_Class/index.html

Scrolling to particular row: 
query("pickerView",[{selectRow:3},{inComponent:0},{animated:1}])



Read elements from picker view
query("pickerView",:delegate, [{pickerView:nil},{titleForRow:3},{forComponent:0}])
Count Number of items in picker view

 query("pickerView",[{selectedRowInComponent:0}])



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