watir-webdriver –> Ruby gem

Installation:

1. Install Ruby

2. Open Command Prompt >gem update –system

3. >gem install watir-webdriver

Usage:

The same script will work for multiple browsers like IE,FF,Chrome.

 

Code:

 

FOR IE :

require 'watir-webdriver'

  browser = Watir::Browser.new :ie
  browser.goto "http://google.com"
  browser.text_field(:name => 'q').set("ruby watir watir-webdriver")
  browser.button(:name => 'btnG').click
  puts browser.url
  browser.close

FOR Firefox,
change the second line  --> browser = Watir::Browser.new :firefox

For Chrome,
change the second line  --> browser = Watir::Browser.new :chrome

Overview about Watir-webdriver :

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s