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

Recommended

PDF
Memory efficient pytorch
Hyungjoo Cho
 
PPT
Wi fi protected-access
bhanu4ugood1
 
PDF
Spellcaster Cresting Wilds
Silver Caprice
 
PDF
Catalogue pièces détachées N1 : WC au sol et suspendus, réservoirs de chasse,...
Allia_Salle_De_Bains
 
PDF
The Daily Throne Room
Silver Caprice
 
PDF
Champions
Silver Caprice
 
PDF
Bonus to Bonus versus
Silver Caprice
 
PPT
Automated Testing With Watir
Timothy Fisher
 
PDF
Automated Testing with Ruby
Keith Pitty
 
PPT
Watir
Sai Venkat
 
PPT
What you can do In WatiR
Wesley Chen
 
PDF
watir-webdriver
jariba
 
PPT
Watir Presentation Sumanth Krishna. A
Sumanth krishna
 
PPTX
FOSDEM2016 - Ruby and OMR
Charlie Gracie
 
DOC
Selenium Automation Using Ruby
Kumari Warsha Goel
 
PPT
Keyword Driven Framework using WATIR
Nivetha Padmanaban
 
PDF
프로그래머로 부터 배우는 코딩 기술 (プログラマから学ぶコーディングテクニック)
Mayuko Sekiya
 
PDF
Introduction to Selenium and Ruby
Ynon Perek
 
PPT
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...
Sla Va
 
PPTX
Page object from the ground up by Joe Beale
QA or the Highway
 
PPTX
Page object from the ground up.ppt
Joseph Beale
 
ODP
An Overview of Node.js
Ayush Mishra
 
PDF
WebMatrix, see what the matrix can do for you!!
Frédéric Harper
 
PPT
.NET Recommended Resources
Greg Sohl
 
PPS
Hacking Client Side Insecurities
amiable_indian
 
PPTX
Test Automation using Ruby
Sla Va
 
PDF
DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!
Frédéric Harper
 
PDF
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Anna Klepacka
 
PPTX
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Tom Johnson
 
PDF
Node Up And Running Scalable Serverside Code With Javascript 1st Edition Tom ...
nunleyagika
 

More Related Content

Viewers also liked (10)

PDF
Automated Testing with Ruby
Keith Pitty
 
PPT
Watir
Sai Venkat
 
PPT
What you can do In WatiR
Wesley Chen
 
PDF
watir-webdriver
jariba
 
PPT
Watir Presentation Sumanth Krishna. A
Sumanth krishna
 
PPTX
FOSDEM2016 - Ruby and OMR
Charlie Gracie
 
DOC
Selenium Automation Using Ruby
Kumari Warsha Goel
 
PPT
Keyword Driven Framework using WATIR
Nivetha Padmanaban
 
PDF
프로그래머로 부터 배우는 코딩 기술 (プログラマから学ぶコーディングテクニック)
Mayuko Sekiya
 
PDF
Introduction to Selenium and Ruby
Ynon Perek
 
Automated Testing with Ruby
Keith Pitty
 
Watir
Sai Venkat
 
What you can do In WatiR
Wesley Chen
 
watir-webdriver
jariba
 
Watir Presentation Sumanth Krishna. A
Sumanth krishna
 
FOSDEM2016 - Ruby and OMR
Charlie Gracie
 
Selenium Automation Using Ruby
Kumari Warsha Goel
 
Keyword Driven Framework using WATIR
Nivetha Padmanaban
 
프로그래머로 부터 배우는 코딩 기술 (プログラマから学ぶコーディングテクニック)
Mayuko Sekiya
 
Introduction to Selenium and Ruby
Ynon Perek
 

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

PPT
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...
Sla Va
 
PPTX
Page object from the ground up by Joe Beale
QA or the Highway
 
PPTX
Page object from the ground up.ppt
Joseph Beale
 
ODP
An Overview of Node.js
Ayush Mishra
 
PDF
WebMatrix, see what the matrix can do for you!!
Frédéric Harper
 
PPT
.NET Recommended Resources
Greg Sohl
 
PPS
Hacking Client Side Insecurities
amiable_indian
 
PPTX
Test Automation using Ruby
Sla Va
 
PDF
DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!
Frédéric Harper
 
PDF
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Anna Klepacka
 
PPTX
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Tom Johnson
 
PDF
Node Up And Running Scalable Serverside Code With Javascript 1st Edition Tom ...
nunleyagika
 
PPTX
JavaScript : A trending scripting language
AbhayDhupar
 
PPTX
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
itsatony
 
PPT
(In)Security Implication in the JS Universe
Stefano Di Paola
 
PPTX
Cross Browser Automation Testing Using Watir
Sarah Elson
 
PDF
Opa Up And Running Henri Binsztok Adam Koprowski Ida Swarczewskaja
valdeyyampis
 
PPTX
Microsoft WebMatrix Platform Overview
Spiffy
 
PDF
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Ryan Weaver
 
PDF
Web Development Presentation
TurnToTech
 
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...
Sla Va
 
Page object from the ground up by Joe Beale
QA or the Highway
 
Page object from the ground up.ppt
Joseph Beale
 
An Overview of Node.js
Ayush Mishra
 
WebMatrix, see what the matrix can do for you!!
Frédéric Harper
 
.NET Recommended Resources
Greg Sohl
 
Hacking Client Side Insecurities
amiable_indian
 
Test Automation using Ruby
Sla Va
 
DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!
Frédéric Harper
 
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Anna Klepacka
 
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Tom Johnson
 
Node Up And Running Scalable Serverside Code With Javascript 1st Edition Tom ...
nunleyagika
 
JavaScript : A trending scripting language
AbhayDhupar
 
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
itsatony
 
(In)Security Implication in the JS Universe
Stefano Di Paola
 
Cross Browser Automation Testing Using Watir
Sarah Elson
 
Opa Up And Running Henri Binsztok Adam Koprowski Ida Swarczewskaja
valdeyyampis
 
Microsoft WebMatrix Platform Overview
Spiffy
 
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Ryan Weaver
 
Web Development Presentation
TurnToTech
 
Ad

More from Mindfire Solutions (20)

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

Recently uploaded (20)

DOCX
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
PPTX
declaration of Variables and constants.pptx
meemee7378
 
PPTX
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Muhammad Fahad Bashir
 
PDF
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
PDF
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
 
PPTX
From Code to Commerce, a Backend Java Developer's Galactic Journey into Ecomm...
Jamie Coleman
 
PDF
University Campus Navigation for All - Peak of Data & AI
Safe Software
 
PDF
Simplify Task, Team, and Project Management with Orangescrum Work
Orangescrum
 
PDF
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
PPTX
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 
PDF
Heat Treatment Process Automation in India
Reckers Mechatronics
 
PPT
Complete Guideliness to Build an Effective Maintenance Plan.ppt
QualityzeInc1
 
PPTX
Top Time Tracking Solutions for Accountants
oliviareed320
 
PPTX
Simplify Insurance Regulations with Compliance Management Software
Insurance Tech Services
 
PPTX
AI for PV: Development and Governance for a Regulated Industry
Biologit
 
PPTX
IObit Driver Booster Pro 12 Crack Latest Version Download
pcprocore
 
PDF
A Guide to Telemedicine Software Development.pdf
Olivero Bozzelli
 
PPTX
Sap basis role in public cloud in s/4hana.pptx
htmlprogrammer987
 
PDF
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
 
PPTX
arctitecture application system design os dsa
za241967
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
declaration of Variables and constants.pptx
meemee7378
 
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Muhammad Fahad Bashir
 
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
 
From Code to Commerce, a Backend Java Developer's Galactic Journey into Ecomm...
Jamie Coleman
 
University Campus Navigation for All - Peak of Data & AI
Safe Software
 
Simplify Task, Team, and Project Management with Orangescrum Work
Orangescrum
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 
Heat Treatment Process Automation in India
Reckers Mechatronics
 
Complete Guideliness to Build an Effective Maintenance Plan.ppt
QualityzeInc1
 
Top Time Tracking Solutions for Accountants
oliviareed320
 
Simplify Insurance Regulations with Compliance Management Software
Insurance Tech Services
 
AI for PV: Development and Governance for a Regulated Industry
Biologit
 
IObit Driver Booster Pro 12 Crack Latest Version Download
pcprocore
 
A Guide to Telemedicine Software Development.pdf
Olivero Bozzelli
 
Sap basis role in public cloud in s/4hana.pptx
htmlprogrammer987
 
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
 
arctitecture application system design os dsa
za241967
 

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