Tuesday, 31 March 2015

Headless gem for simulating user

Headless is used in automation testing to simulate the user.
gem Headless is having dependency on selenium web-driver.
the advantage of headless is that it does not opens a browser window.
selenium web-driver is used to start the browser and simulate user activities

firstly install headless gem by command:

gem install headless


Create a new ruby file and save this code in that file.

require 'rubygems'
require 'headless'
require 'selenium-webdriver'

headless = Headless.new
headless.start

driver = Selenium::WebDriver.for :firefox
driver.navigate.to 'http://blog.grepruby.com'
puts driver.title

headless.destroy


Then run this command form console:

$ ruby file_name_with_path


you will found the title printed on console:

Grep Ruby Practices

try it yourself by replacing the url in this file.

No comments:

Post a Comment