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

PPTX
DEVSECOPS.pptx
PDF
PDF
Demystifying DevSecOps
PPTX
Disaster Recovery Strategies - AWS Siklab 2022.pptx
PDF
Secure Code Review 101
PPTX
Agile DevOps Transformation Strategy
ODP
OWASP Secure Coding
PDF
The Paved Road at Netflix
DEVSECOPS.pptx
Demystifying DevSecOps
Disaster Recovery Strategies - AWS Siklab 2022.pptx
Secure Code Review 101
Agile DevOps Transformation Strategy
OWASP Secure Coding
The Paved Road at Netflix

What's hot (20)

PPTX
Agile Release Planning
PDF
DevSecOps What Why and How
PPTX
DevSecOps: Security With DevOps
PPTX
2021 五月 Veeam 多雲解決方案 (完整版本)
PDF
How to Monitoring the SRE Golden Signals (E-Book)
PPTX
password cracking and Key logger
PPT
Automated Testing With Watir
PDF
Digital Threat Landscape
PPTX
Agile Retrospectives
PDF
#ATAGTR2019 Presentation "DevSecOps with GitLab" By Avishkar Nikale
PDF
Introduction to DevSecOps
PPTX
DevSecOps without DevOps is Just Security
PPTX
Track code quality with SonarQube
PDF
DevOps Powerpoint Presentation Slides
PDF
DevSecOps Implementation Journey
PDF
Dev ops 簡介
PPTX
WannaCry ransomware outbreak - what you need to know
PPTX
Ransomware
PPT
Ransomware - The Growing Threat
Agile Release Planning
DevSecOps What Why and How
DevSecOps: Security With DevOps
2021 五月 Veeam 多雲解決方案 (完整版本)
How to Monitoring the SRE Golden Signals (E-Book)
password cracking and Key logger
Automated Testing With Watir
Digital Threat Landscape
Agile Retrospectives
#ATAGTR2019 Presentation "DevSecOps with GitLab" By Avishkar Nikale
Introduction to DevSecOps
DevSecOps without DevOps is Just Security
Track code quality with SonarQube
DevOps Powerpoint Presentation Slides
DevSecOps Implementation Journey
Dev ops 簡介
WannaCry ransomware outbreak - what you need to know
Ransomware
Ransomware - The Growing Threat
Ad

Viewers also liked (10)

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 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

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
Salesforce Agentforce AI Implementation.pdf
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PPTX
Cybersecurity: Protecting the Digital World
PPTX
CNN LeNet5 Architecture: Neural Networks
PDF
Designing Intelligence for the Shop Floor.pdf
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
PDF
CCleaner 6.39.11548 Crack 2025 License Key
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PPTX
Trending Python Topics for Data Visualization in 2025
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PDF
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
PPTX
Computer Software - Technology and Livelihood Education
PPTX
GSA Content Generator Crack (2025 Latest)
PDF
AI Guide for Business Growth - Arna Softech
PDF
Time Tracking Features That Teams and Organizations Actually Need
PDF
Visual explanation of Dijkstra's Algorithm using Python
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
Salesforce Agentforce AI Implementation.pdf
DNT Brochure 2025 – ISV Solutions @ D365
Cybersecurity: Protecting the Digital World
CNN LeNet5 Architecture: Neural Networks
Designing Intelligence for the Shop Floor.pdf
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
CCleaner 6.39.11548 Crack 2025 License Key
Wondershare Recoverit Full Crack New Version (Latest 2025)
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
How Tridens DevSecOps Ensures Compliance, Security, and Agility
Trending Python Topics for Data Visualization in 2025
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
Computer Software - Technology and Livelihood Education
GSA Content Generator Crack (2025 Latest)
AI Guide for Business Growth - Arna Softech
Time Tracking Features That Teams and Organizations Actually Need
Visual explanation of Dijkstra's Algorithm using Python
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
Weekly report ppt - harsh dattuprasad patel.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