SlideShare a Scribd company logo
Introduction to Ruby-Watir
PRESENTED BY: SUBHASISH PATTANAIK
SOFTWARE QUALITY ANALYST
MINDFIRE SOLUTIONS
Contents

What is Watir?

What WATIR is not...

What is Ruby?

How does Watir works?

Why Watir?

Setting up WATIR

Learning WATIR

IDE's for Ruby-Watir

Small Scripts
What is WATIR?

Web Application Testing In Ruby

It is a library for the Ruby language which drives Firefox,
Google Chrome, Internet Explorer the same way people
do;

clicks links,

fills in forms,

and presses buttons.

Watir can also check results, such as whether expected
text appears on the page.

It can be used to test all types of web applications
(ASP.Net, JSP, PHP, Rails, etc…)

Open Source – written by Bret Pettichord, Paul Rogers and
many other contributors.
What WATIR is not...

Watir is not a record/playback tool.

However, there are several recorders “out there”

WatirMaker

Watir WebRecorder

Webmetrics RIA Script Recorder (most recent discussion…they
are considering open sourcing their application)

Watir is not a link checker.

However, you can easily write your own link checker and customize
it to your specific needs.

Watir is not a test case management tool.

However, you can write one in Ruby if desired.

Doesn’t test Flash or Applets.
What is Ruby?

Full featured Object Oriented scripting language

Made “famous” for it’s web application framework Rails. (Ruby on
Rails)

Interpreted rather than compiled

Written by Matz (Yukihiro Matsumoto)

Started in 1994

Written in C

Will work on any platform that has a C compiler

Windows

Linux
How does Watir works?

Uses the COM interface of Internet Explorer (IE)

Allows an external program to control IE

Similar interfaces exist for Word, Excel, PowerPoint and Outlook.

Full access to the contents of an HTML page

Provides different ways to access objects
The Big Question :
Why Watir?
Why Watir? (contd...)

As a testing tool: It’s as robust & sophisticated as
‘professional’ tools such as Rational, Mercury & Segue.

As a library of a programming language [Ruby ] : It’s powerful.

(You have the power to connect to databases, read data files,
export XML, structure your code into reusable libraries, and
pretty much anything else you can think of…)

No “Vendor-script”

It’s simple – elegant – INTUITIVE

It has a supportive online community for when you get ‘stuck’.
Setting up WATIR
Learning WATIR :
Getting Started
As you start to get into Ruby/Watir you’ll want some Good
information at your fingertips!
Introductory Documentation:

Watir homepage: http://watir.com

Watir User Guide: http://en.wikipedia.org/wiki/watir
Books:

Everyday Scripting with Ruby: for Teams, Testers, and You:
http://pragprog.com/book/bmsft/everyday-scripting-with-ruby

Programming Ruby (Online Book): http://ruby-
doc.com/docs/ProgrammingRuby/
Learning WATIR :
More In-Depth
Forums:

Watir General Forum (now on Google Groups):
http://groups.google.com/group/watir-general?hl=en

Watir Search (web interface that searches 7 Watir sites):
https://www.google.com/cse/home?
cx=007267089725385613265:gmydx5gtw6u

Online Ruby Information: http://www.ruby-doc.org/

Watir Book : https://github.com/watir/watirbook
Development
Environment's(IDE's)
for Ruby
Use any text editor as an IDE:

ScITE (Free)

Included with your ruby download.

Notepad ++(Free)

Eclipse (using RDT Plugin)

http://rubyeclipse.sourceforge.net/

Ruby In Steel (Free - $199) (Add-on to VS.Net )

http://www.sapphiresteel.com

Komodo IDE ($295) / Komodo Edit (Free)

http://www.activestate.com
Using Ruby's
Interactive Command
Interpreter (IRB)

What is it?

Interactive Ruby.

It evaluates Ruby expressions from the Terminal.

Used To:

Run quick experiments to see if things will work in your tests
– irb (main) : 001 : 0> require 'watir'.
– irb (main) : 002 : 0> require 'watir-webdriver'.
– irb (main) : 003 : 0> browser = Watir::Browser.new'.
– irb (main) : 004 : 0> browser.goto 'http://google.com'
Let's Get Started..
It’s time to turn on
the Watir!
Anatomy of Watir
Script
# Loads the watir gems
require 'watir'
# Loads all the gems required to drive firefox and chrome
require 'watir-webdriver'
# To open a new browser(firefox)
browser = Watir::Browser.new :firefox
# Navigate to the below URL
browser.goto 'http://ourgoalplan.com/'
# Identify the field to which data is to be inserted and enter the value
browser.text_field(:name => 'txtName').set 'subhasish.pattanaik'
browser.text_field(:name => 'txtPassword').set 'subh_2727'
# To click the button
browser.button( :id => 'btnLogin').click
# To enter the goals in the Text area
browser.text_field( :id => 'ucAddGoal_txtAddGoal').set '[CIRRATA-
WP] : TESTING + ISSUES REPORTING[EST - 2HRS]' + "n" +
'[COMMETTE] : TESTING + ISSUES REPORTING[EST - 2HRS]'
# To click on the Add Goal button
browser.button( :id => 'ucAddGoal_btnAddGoal').click
Use Watir

Using Watir API is very easy.

Reference the Watir API using the keyword 'require' and start
coding.
require 'watir'
require 'watir-webdriver'
browser = Watir::Browser.new :firefox
Web Pages are all
about Objects

Web pages are developed with objects:

Links, buttons, tables, drop-down boxes, forms, frames, etc.

Watir scripts need to access these objects &
manipulate them just as a user would.

Clicking, submitting, typing, selecting, etc…
Manipulating Web Page
Objects:Link
Manipulating Web Page
Objects:Checkbox
Manipulating Web Page
Objects:Radio Buttons
Manipulating Web Page
Objects:Selection Boxes
Manipulating Web Page
Objects:Text Fields
Manipulating Web Page
Objects:Buttons
A Closer Look... at the
structure
browser.button(:value, "Click
Me").click
[Variable] . [method] (: [element] , “ [unique identifier]” . [method]
Test Automation is
MORE than Identifying
Objects

Identifying objects is currently the most time
consuming part of creating your test scripts…

However, after your objects have been identified
& manipulated: you want to “Test” them!

You’ll want to create “PASS” or “FAIL”
scenarios.
…This is the most sophisticated part
of your scripts. Will learn more on this
in next seminar...
Congratulations!
You are on your Way
…to programming the Ruby-Watir way !!
References
1. https://github.com/watir/watirbook
2. http://watir.com/
3. http://watir.com/examples/
4. http://www.thoughtworks.com/insights/articles/automated-
testing-using-ruby-and-watir
5. http://watirwebdriver.com/
6. http://www.rubywatir.com/
7. http://en.wikipedia.org/wiki/Watir
Thank You
Any Queries???
Introduction To Ruby Watir (Web Application Testing In Ruby)

More Related Content

PPT
Fundamental File Processing Operations
PPTX
Server Side Programming
PDF
Authentication Modules For Linux - PAM Architecture
PDF
Rest api with Python
ODP
Virtual Hosts Configuration with Weblogic Server
PDF
BitTorrent Seminar Report
PDF
Ftp server
PPTX
UAS ppt Mesin Turing beserta contoh soal
Fundamental File Processing Operations
Server Side Programming
Authentication Modules For Linux - PAM Architecture
Rest api with Python
Virtual Hosts Configuration with Weblogic Server
BitTorrent Seminar Report
Ftp server
UAS ppt Mesin Turing beserta contoh soal

Viewers also liked (11)

PPT
Automated Testing With Watir
PDF
Automated Testing with Ruby
PPT
Watir
PPT
What you can do In WatiR
PDF
watir-webdriver
PPT
Watir Presentation Sumanth Krishna. A
PPTX
FOSDEM2016 - Ruby and OMR
DOC
Selenium Automation Using Ruby
PPT
Keyword Driven Framework using WATIR
PDF
프로그래머로 부터 배우는 코딩 기술 (プログラマから学ぶコーディングテクニック)
PDF
Introduction to Selenium and Ruby
Automated Testing With Watir
Automated Testing with Ruby
Watir
What you can do In WatiR
watir-webdriver
Watir Presentation Sumanth Krishna. A
FOSDEM2016 - Ruby and OMR
Selenium Automation Using Ruby
Keyword Driven Framework using WATIR
프로그래머로 부터 배우는 코딩 기술 (プログラマから学ぶコーディングテクニック)
Introduction to Selenium and Ruby
Ad

Similar to Introduction To Ruby Watir (Web Application Testing In Ruby) (20)

PPTX
Test Automation using Ruby
PPTX
Page object from the ground up.ppt
PPTX
Page object from the ground up by Joe Beale
PPTX
Watir The Beginning
PPT
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...
PPTX
Watir - The Beginning
PPTX
Cross Browser Automation Testing Using Watir
PDF
Espremendo melancia | TDC2014 Floripa | Chaordic
PDF
Espremendo melancia | TDC2014 Floripa | Chaordic
PDF
ruby pentest
PPTX
Cucumber From the Ground Up - Joseph Beale
PPT
Jonas Skjoldan - Automatic GUI test with Ruby and Watir
PDF
I'm watir
PPT
FireWatir - Web Application Testing Using Ruby and Firefox
PPT
watir-webdriver
PDF
0201710897
PDF
Ruby tutorial
PDF
Ruby Presentation
PDF
Workin On The Rails Road
PPTX
Ruby And Ruby On Rails
Test Automation using Ruby
Page object from the ground up.ppt
Page object from the ground up by Joe Beale
Watir The Beginning
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...
Watir - The Beginning
Cross Browser Automation Testing Using Watir
Espremendo melancia | TDC2014 Floripa | Chaordic
Espremendo melancia | TDC2014 Floripa | Chaordic
ruby pentest
Cucumber From the Ground Up - Joseph Beale
Jonas Skjoldan - Automatic GUI test with Ruby and Watir
I'm watir
FireWatir - Web Application Testing Using Ruby and Firefox
watir-webdriver
0201710897
Ruby tutorial
Ruby Presentation
Workin On The Rails Road
Ruby And Ruby On Rails
Ad

More from Mindfire Solutions (20)

PDF
Physician Search and Review
PDF
diet management app
PDF
Business Technology Solution
PDF
Remote Health Monitoring
PDF
Influencer Marketing Solution
PPT
High Availability of Azure Applications
PPTX
IOT Hands On
PPTX
Glimpse of Loops Vs Set
ODP
Oracle Sql Developer-Getting Started
PPT
Adaptive Layout In iOS 8
PPT
Introduction to Auto-layout : iOS/Mac
PPT
LINQPad - utility Tool
PPT
Get started with watch kit development
PPTX
Swift vs Objective-C
ODP
Material Design in Android
ODP
Introduction to OData
PPT
Ext js Part 2- MVC
PPT
ExtJs Basic Part-1
PPT
Spring Security Introduction
Physician Search and Review
diet management app
Business Technology Solution
Remote Health Monitoring
Influencer Marketing Solution
High Availability of Azure Applications
IOT Hands On
Glimpse of Loops Vs Set
Oracle Sql Developer-Getting Started
Adaptive Layout In iOS 8
Introduction to Auto-layout : iOS/Mac
LINQPad - utility Tool
Get started with watch kit development
Swift vs Objective-C
Material Design in Android
Introduction to OData
Ext js Part 2- MVC
ExtJs Basic Part-1
Spring Security Introduction

Recently uploaded (20)

PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
System and Network Administration Chapter 2
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
ai tools demonstartion for schools and inter college
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
medical staffing services at VALiNTRY
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPT
Introduction Database Management System for Course Database
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Introduction to Artificial Intelligence
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Upgrade and Innovation Strategies for SAP ERP Customers
System and Network Administration Chapter 2
Design an Analysis of Algorithms II-SECS-1021-03
ai tools demonstartion for schools and inter college
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
medical staffing services at VALiNTRY
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Introduction Database Management System for Course Database
ManageIQ - Sprint 268 Review - Slide Deck
PTS Company Brochure 2025 (1).pdf.......
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Introduction to Artificial Intelligence
Wondershare Filmora 15 Crack With Activation Key [2025
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
VVF-Customer-Presentation2025-Ver1.9.pptx

Introduction To Ruby Watir (Web Application Testing In Ruby)

  • 1. Introduction to Ruby-Watir PRESENTED BY: SUBHASISH PATTANAIK SOFTWARE QUALITY ANALYST MINDFIRE SOLUTIONS
  • 2. Contents  What is Watir?  What WATIR is not...  What is Ruby?  How does Watir works?  Why Watir?  Setting up WATIR  Learning WATIR  IDE's for Ruby-Watir  Small Scripts
  • 3. What is WATIR?  Web Application Testing In Ruby  It is a library for the Ruby language which drives Firefox, Google Chrome, Internet Explorer the same way people do;  clicks links,  fills in forms,  and presses buttons.  Watir can also check results, such as whether expected text appears on the page.  It can be used to test all types of web applications (ASP.Net, JSP, PHP, Rails, etc…)  Open Source – written by Bret Pettichord, Paul Rogers and many other contributors.
  • 4. What WATIR is not...  Watir is not a record/playback tool.  However, there are several recorders “out there”  WatirMaker  Watir WebRecorder  Webmetrics RIA Script Recorder (most recent discussion…they are considering open sourcing their application)  Watir is not a link checker.  However, you can easily write your own link checker and customize it to your specific needs.  Watir is not a test case management tool.  However, you can write one in Ruby if desired.  Doesn’t test Flash or Applets.
  • 5. What is Ruby?  Full featured Object Oriented scripting language  Made “famous” for it’s web application framework Rails. (Ruby on Rails)  Interpreted rather than compiled  Written by Matz (Yukihiro Matsumoto)  Started in 1994  Written in C  Will work on any platform that has a C compiler  Windows  Linux
  • 6. How does Watir works?  Uses the COM interface of Internet Explorer (IE)  Allows an external program to control IE  Similar interfaces exist for Word, Excel, PowerPoint and Outlook.  Full access to the contents of an HTML page  Provides different ways to access objects
  • 7. The Big Question : Why Watir?
  • 8. Why Watir? (contd...)  As a testing tool: It’s as robust & sophisticated as ‘professional’ tools such as Rational, Mercury & Segue.  As a library of a programming language [Ruby ] : It’s powerful.  (You have the power to connect to databases, read data files, export XML, structure your code into reusable libraries, and pretty much anything else you can think of…)  No “Vendor-script”  It’s simple – elegant – INTUITIVE  It has a supportive online community for when you get ‘stuck’.
  • 10. Learning WATIR : Getting Started As you start to get into Ruby/Watir you’ll want some Good information at your fingertips! Introductory Documentation:  Watir homepage: http://watir.com  Watir User Guide: http://en.wikipedia.org/wiki/watir Books:  Everyday Scripting with Ruby: for Teams, Testers, and You: http://pragprog.com/book/bmsft/everyday-scripting-with-ruby  Programming Ruby (Online Book): http://ruby- doc.com/docs/ProgrammingRuby/
  • 11. Learning WATIR : More In-Depth Forums:  Watir General Forum (now on Google Groups): http://groups.google.com/group/watir-general?hl=en  Watir Search (web interface that searches 7 Watir sites): https://www.google.com/cse/home? cx=007267089725385613265:gmydx5gtw6u  Online Ruby Information: http://www.ruby-doc.org/  Watir Book : https://github.com/watir/watirbook
  • 12. Development Environment's(IDE's) for Ruby Use any text editor as an IDE:  ScITE (Free)  Included with your ruby download.  Notepad ++(Free)  Eclipse (using RDT Plugin)  http://rubyeclipse.sourceforge.net/  Ruby In Steel (Free - $199) (Add-on to VS.Net )  http://www.sapphiresteel.com  Komodo IDE ($295) / Komodo Edit (Free)  http://www.activestate.com
  • 13. Using Ruby's Interactive Command Interpreter (IRB)  What is it?  Interactive Ruby.  It evaluates Ruby expressions from the Terminal.  Used To:  Run quick experiments to see if things will work in your tests – irb (main) : 001 : 0> require 'watir'. – irb (main) : 002 : 0> require 'watir-webdriver'. – irb (main) : 003 : 0> browser = Watir::Browser.new'. – irb (main) : 004 : 0> browser.goto 'http://google.com'
  • 14. Let's Get Started.. It’s time to turn on the Watir!
  • 15. Anatomy of Watir Script # Loads the watir gems require 'watir' # Loads all the gems required to drive firefox and chrome require 'watir-webdriver' # To open a new browser(firefox) browser = Watir::Browser.new :firefox # Navigate to the below URL browser.goto 'http://ourgoalplan.com/' # Identify the field to which data is to be inserted and enter the value browser.text_field(:name => 'txtName').set 'subhasish.pattanaik' browser.text_field(:name => 'txtPassword').set 'subh_2727' # To click the button browser.button( :id => 'btnLogin').click # To enter the goals in the Text area browser.text_field( :id => 'ucAddGoal_txtAddGoal').set '[CIRRATA- WP] : TESTING + ISSUES REPORTING[EST - 2HRS]' + "n" + '[COMMETTE] : TESTING + ISSUES REPORTING[EST - 2HRS]' # To click on the Add Goal button browser.button( :id => 'ucAddGoal_btnAddGoal').click
  • 16. Use Watir  Using Watir API is very easy.  Reference the Watir API using the keyword 'require' and start coding. require 'watir' require 'watir-webdriver' browser = Watir::Browser.new :firefox
  • 17. Web Pages are all about Objects  Web pages are developed with objects:  Links, buttons, tables, drop-down boxes, forms, frames, etc.  Watir scripts need to access these objects & manipulate them just as a user would.  Clicking, submitting, typing, selecting, etc…
  • 24. A Closer Look... at the structure browser.button(:value, "Click Me").click [Variable] . [method] (: [element] , “ [unique identifier]” . [method]
  • 25. Test Automation is MORE than Identifying Objects  Identifying objects is currently the most time consuming part of creating your test scripts…  However, after your objects have been identified & manipulated: you want to “Test” them!  You’ll want to create “PASS” or “FAIL” scenarios. …This is the most sophisticated part of your scripts. Will learn more on this in next seminar...
  • 26. Congratulations! You are on your Way …to programming the Ruby-Watir way !!
  • 27. References 1. https://github.com/watir/watirbook 2. http://watir.com/ 3. http://watir.com/examples/ 4. http://www.thoughtworks.com/insights/articles/automated- testing-using-ruby-and-watir 5. http://watirwebdriver.com/ 6. http://www.rubywatir.com/ 7. http://en.wikipedia.org/wiki/Watir