Author Archive

Mirror your Android Phone on Mac/PC

February 1, 2016 Leave a comment

Vysor is a Chrome add-on that allows you to mirror your Android phone on your Mac or PC when doing presentation through your mobile phone.

So far this is the easiest way as it does not require installation of any application whatsoever, plus it allows you to mirror multiple devices as long as it is connected to your machine.

  1. Launch your Chrome browser and go to Chrome webstore

2. Search for Vysor and click “Add to Chrome” button

Screen Shot 2016-01-20 at 11.08.20 am

3. Connect your Android phone to your Mac/PC via USB

4. Launch the Vysor via the Chrome webstore or Chrome App Launcher

Screen Shot 2016-01-20 at 10.49.45 am

5. Choose the device that you want to share

Screen Shot 2016-01-20 at 10.50.55 am

6. Now you can navigate through your mobile phone and project all the user actions in your desktop.

Screen Shot 2016-01-20 at 10.55.00 am

Categories: Uncategorized

Cucumber: Passing Test Data as Table from Scenario

January 20, 2016 Leave a comment

While we can pass test data as table from the feature file through Scenario Outline:

Scenario Outline: User updates user information
 Given I login to application
 And I go to user profile page
 And I enter "<gender>" into field of "gender_element";
 And I enter "<age>" into field of "age_element";
 And I enter "<location>" into field of "location_element";
 Then I verify user updates are saved
 | gender | age | location |
 | Female | 20 | Singapore |

Here’s another option to pass your data in table format through your step definition.

Scenario: User updates user information
 Given I login to application
 And I go to user profile page
 When I update user information with options:
  | Gender | Female |
  | Age | 20 |
  | Location | Singapore |
 Then I verify user updates are saved

#Step Definitions File

#step definition to populate textfields
Then /^I enter "(.*)" into field of "(.*)"$/ do |value, field|
 textfield(I18n.translate!(field)).send_keys value

#step definition that accepts test data from the feature file as table
When /^I update user information(?: with options:)?$/ do |table|

 options = table.rows_hash
 step %Q[I enter "#{options['Gender']}" into field of "gender_element"]
 step %Q[I enter "#{options['Age']}" into field of "age_element"]
 step %Q[I enter "#{options['Location']}" into field of "location_element"]
 step %Q[I press button labelled "bt_address_suggestion_use_this"] 

#step definition that accepts test data from the feature file as table with default value
When /^I update user information(?: with options:)?$/ do |table|
 default_value = {
 'Age' = "18",
 'Location' = "United States"
 options = default_value.merge(table.rows_hash)
 step %Q[I enter "#{options['Gender']}" into field of "gender_element"]
 step %Q[I enter "#{options['Age']}" into field of "age_element"]
 step %Q[I enter "#{options['Location']}" into field of "location_element"]
 step %Q[I press button labelled "bt_address_suggestion_use_this"]
Categories: cucumber, ruby, selenium

Cucumber: Using JSON Parser

February 25, 2015 Leave a comment

JavaScript Object Notation(JSON) is a lightweight data-interchange format useful to generate and parse data

Sample Data:

{‘user’:{‘FirstName’:’User1′, ‘LastName’:’Sample’, ‘Gender’:’Female’, ‘BirthDate’:’01/01/1990′}}

Suppose we are to use the above user data, parse it into an hash and use the array hash as input to a sign up screen.

Here’s a snippet of how to use JSON in this particular scenario

require “json”

my_data = "{'user':{'FirstName':'User', 'LastName':'Sample', 'Gender':'Female', 'BirthDate':'01/01/1990'}}"

##method to parse user data

def getNewUserData

@new_user = JSON.parse my_data


:firstName => new_user['user']['FirstName'],

:lastName => new_user['user']['LastName'],

:gender => new_user['user']['Gender'],

:birthDate => new_user['user']['BirthDate']



##method to populate the sign up screen

def fillOutSignUpScreen

step %Q[I enter "#{@new_user[:firstName]}" to the "signup.firstname"]

step %Q[I enter "#{@new_user[:lastName]}" to the "signup.lastname"]

step %Q[I enter "#{@new_user[:gender]}" to the "signup.gender"]

step %Q[I enter "#{@new_user[:birthDate]}" to the "signup.birthdate"]


For more functions and complete library you may refer to

Categories: ruby Tags: ,

Ruby: Using URI and HTTPClient

February 25, 2015 Leave a comment

HTTPClient provides API library for user to access web resource using HTTP

This would be helpful if you need to access a different web URL other than your base URL that you used in your automation and validate the content of the page.

Here’s a snippet of how to use HTTPClient in this particular scenario

require “httpclient”

my_url = “http://CheckThisOut:8080”

##method to access my_url using URI

def accessPage


uri_parsed = URI.parse(my_url)

client =

client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE

client.no_proxy =

uri = my_url

#invoke url to take the page content

puts “Accessing: #{uri}”

resp = client.get uri, :header => {’Accept’ =>‘application/json’}


puts(“Error encountered: #{$!.inspect}”)



puts "response: status = #{resp.status}"

puts "response: body = #{resp.body}"

fail "bad response #{resp.status} #{resp.reason}" unless resp.status == HTTP::Status::OK

page_content = resp.body

return page_content


For more functions and complete library you may refer to

Categories: Uncategorized Tags: , ,

Useful Git Commands

January 25, 2015 Leave a comment

As our project migrated from SVN to GIT repository, I thought of writing a post of the usual git commands which I find helpful where I could easily refer to.

**Set up Local Repository

#clone a repository into a new directory locally

git clone <SSH key>

#checkout a branch or path to the working tree

git checkout <branch name>

**Working with Branches

#display all the available branches in your local, highlighting the active branch

git branch

#download all/new branches

git fetch

#switch working branch

git checkout <branch name>

#create new branch locally

git checkout -b <branch name>

#push newly created branch to remote

git push -u origin <branch name>

**Committing Local Changes to remote

#show staged files for commit, not staged files for commit and untracked files.

git status

#include what will be committed, stage the changes

git add <file>

#discard changes

git checkout — <file>

#to add message for commit

git commit -m “message here”

#take latest commits on the mentioned branch

git pull origin <branch name>

#push local changes to the remote

git push origin <branch name>

Categories: technology Tags:

Cucumber: Verify page content from a data source

July 21, 2014 1 comment

One good practice in “Cuking” is to not crowd your feature files with all the text validations. In this post I’ll be sharing how you can use an external data source to be compared with the actual UI page for content validation purposes.

First prepare your textfile by inputting all the expected content in the page you want to assert. Save this in a your desired location which later on you’ll need to specify in your step definition.

Step Definition

And /^I verify ([^"]*) page content$/ do |page|
 case page
   when 'Terms and Conditions'
     $file = File.expand_path(File.dirname(__FILE__) + '/{location of your file}/terms_and_conditions.txt')
   #you can add other pages to validate within the case
 $content =$file)
 $content.readlines.each do |line|
   puts "#{line}"
   page.text.should have_content("#{line}")

In your feature file assuming all the other step definitions are in place, you’ll just need to call your ‘I verify ([^”]*) page content’ step with the page variable in our example ‘Terms and Conditions’

Scenario: User verify contents of Home page
  Given User go to Terms and Conditions page
  And I verify Terms and Conditions page content

In other cases that you nedd to save your text validations in a csv data source, for example maintaining a csv file with all the expected labels per page:


Your step definition should look something like this:

And /^I verify fields from "([^"]*)"$/ do |page|
  $source = "/{location of your file}/fields.csv"
  FasterCSV.foreach(File.expand_path(File.dirname(__FILE__) + "#{$source}"), :headers => true) do |row|
      if row.header?("#{page}")
        if row["#{page"] != nil
          puts row["#{page}"]
          $field = row["#{page}"]
          page.text.should match(/#{$field}/)
    rescue => e
      raise e

Then in your feature file, you just call the step definition with the csv’s column header as a parameter:

Scenario: User verify contents of Home page
  Given User go to Login page
   Then I verify fields from "Login Page"
   And User go to Registration Page
   Then I verify fields from "Registration Page"

Cucumber: Read from File

November 1, 2012 1 comment

As your automated testing mature, you don’t want to limit users hard coding their application under test or browser driver all in the ENVironment file(env.rb). You can customized your environment by creating a configuration file where you can define variables like applications URL, timeout, database configurations and the like.

From the basic folder structure discussed in Automated Testing with Cucumber + Capybara post, add two more files:

config > environments.yml
support > custom_config.rb

environments.yml – contains all the environment variables that you can use



custom_config.rb – ruby code where you configure your code to read from a specific file

require "erb"

module CustomConfig
 unless defined? @@env_config
 puts "loading environments.yml..."
 env = (ENV['ENVIRONMENT'] && ENV['ENVIRONMENT'].to_sym) || :google
 environments = YAML.load('../../../config/environments.yml', __FILE__))).result)
 @@env_config = environments[env.to_s]
 raise "No config found for environment: #{env}" unless @@env_config

def env_config



Your base folder should look like these by now:

Revised Base Folder

Then edit your env.rb by adding the following lines to your environment file.

require File.expand_path(‘../custom_config’, __FILE__)
include CustomConfig

Also update Capybara.app_host definition to look up to @@env_config. Your env.rb file should be edited to something like this:


require 'capybara'
require 'capybara/cucumber'
require File.expand_path('../custom_config', __FILE__)
include CustomConfig

Capybara.default_driver = :selenium
Capybara.app_host = env_config['app_host']
Capybara.default_wait_time = 20


Notice in line #07 of your env.rb you are basically pointing app host to whatever environment you set in your custom_config.rbenv variable, (see line #06) for this example :google

From here on you should still be able to run your simple_search.feature file without error, the only difference is your code reads now from a specific file – environments.yml, through custom_config.rb.