SlideShare a Scribd company logo
W eb  A pplication  T est  I n  R uby Sumanth Krishna. A www.sumanthkrishna.com
Agenda Introducing the topic Discussion on Testing frameworks/tools and it’s necessity Ruby Installations Architecture Testcases Scope
TAG CLOUD ruby Apache Nginx assertions install webserver FireWatir temp- user WATIR goto html DOM web-applications opensource tests Assertions  get_string   firefox-addon   click hudson SVN  COM  open-source  IE gems  open-QA  ruby  regression  loadrunner  mercury  automatio deployment browers  tools WATIR html DOM  recorder  telnet
Prerequisites Can you believe you really don’t need any special skills to implement this!
What is WATIR? open-source functional testing tool for web-applications Simulate the user actions (filling/submitting forms…) Drives Internet Explorer browser FireWatir – for FireFox Ruby based Various assertions (content-based) Connects to databases Reading data files Exporting data (xml/html/excel…)
Why use WATIR? Free Powerful Simple (easy to use and learn) Excellent Support Strongest Presence Watir/Watin/Watij [ W eb  A pplication  T esting  I n  R uby/. N ET/ J ava ] Huge resource of supporting tools –  Firewatir, Watir Recorder ++, Wet, Cubictest, Visual Studio
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.( underwork )
IE-WATIR Web Application Automation Interface Use the OLE/COM Automation interface to Internet Explorer IE Watir/Ruby DOM
FF-FireWATIR Automation Interface FF FireWatir/Ruby DOM Web Application JSSh
Browser Support IE COM Test Script Component 1 FF JSSH Apple Events V8 Debugger Dragonfly Component 2 Component 3 Component 4 Watir API
Installing: Windows Install Ruby: Use the  Ruby one-click installer for windows   Install the latest gem watir  (ruby packages are called gems) gem install watir And you find the following gems installing… Successfully installed xml-simple-1.0.11 Successfully installed s4t-utils-1.0.4 Successfully installed builder-2.1.2 Successfully installed user-choices-1.1.6 Successfully installed commonwatir-1.6.2 Successfully installed  firewatir-1.6.2 ( to support Firefox ) Successfully installed watir-1.6.2 Successfully installed win32-api-1.3.0-x86-mswin32-60 Successfully installed windows-api-0.3.0 Successfully installed rubyforge-1.0.2 10 gems installed Installation done… let’s move ahead
What Next? Since we are here to test the web-application  Navigate the browser? Find elements on the page? Interact with elements on the page? Check output on the page? Create and use Methods? Create formal test cases?
Step by Step Navigate to the browser #Always Load the Watir library at the top of your script require ‘watir’ Start IE and navigate to a given/different URL IE = Watir::IE.start(‘http://www.qvnatel.com’) IE.goto(“http://free-opensource.qvantel.net/mediawiki//index.php/Main_Page ”) IE.close
Finding <HTML> Elements IE.frame( how, what ) Frame And many, many more (div, label, image, etc…)… IE.form( how, what ) Form IE.link( how, what ) HyperLink IE.radio( how, what ) RadioButton IE.checkbox( how, what ) CheckBox IE.select_list( how, what ) DropDownList IE.button( how, what ) Button IE.text_field( how, what ) TextBox
Interacting with Elements #Set the text field (or text area) specified name specified value.   ie.text_field( :name ,'name').set('value')    #Sets the select with to the specified value ie.select_list( :name ,'name').select('value')  #Click the button with the specified value (label) ie.button( :value ,'value').click #Clicks the link matching 'text'   ie.link( :text ,'text').click #Accessing elements in a &quot;frame&quot; or &quot;iframe&quot; ie.frame( :name ,&quot;someFrame&quot;).text_field( :name ,'name').set('value')
Closer view browser.button( :value , &quot;Click Me&quot;).click [Variable]  .  [method]  (:  [element]  , “  [unique identifier] ”   .  [method]
Checking Output #Get the title of the page ie.title #Get all the text displayed on the page ie.text #Get all the HTML in the body of the page ie.html #Return true if ‘text’ is displayed on the page ie.contains_text('text')
 
Ruby advantage Since WATIR is ruby based web application testing framework, we can customize the script according to our needs. Taking Ruby’s Object Oriented concepts, create more dynamic/customized scripts Use classes & methods effectively Access even the database to validate the data
Test::Unit Assertions
Methods #Here is an example method for logging into a web application. Its two parameters are a user and password (both of which have defaults). It returns an instance of IE def  login(user=“test_admin”,password = “Password123”) ie=Watir::IE.start(‘http://someURL.com/login’) ie.text_field(:name,/user/i).set(user) ie.text_field(:name,/password/i).set(password) ie.button(:value,/login/i).click return  ie  end #Now we can easily login with the default user.. ie = login  #or with a unique user ie = login(“Fred”,”flinstone”)
Full Fledge Test Case require 'test/unit'  #includes Ruby's test case functionality require  ‘ util ’     #Assuming our login method is saved in util.rb #Test cases are contained within classes which extend Ruby’s base test case class class  MyTest  < Test::Unit::TestCase def  setup  #Optional, will be run before each test method.   @ie = login()  #call our login function. end def  test_some_link  #Test methods must begin with &quot;test_“ @ie.link(:text,”some_link”).click  #click on some link #verify that the proper page loaded assert(@ie.contains_text(“My Some Link Page”)) end def  teardown  #Optional, will be run after each test method. @ie.close end end
Installing: Ubuntu Install Ruby:  sudo apt-get install ruby Install the latest gem firewatir  (ruby packages are called gems) sudo gem install firewatir And you find the following gems installing… Successfully installed xml-simple-1.0.11 Successfully installed s4t-utils-1.0.4 Successfully installed builder-2.1.2 Successfully installed user-choices-1.1.6 Successfully installed commonwatir-1.6.2 Successfully installed firewatir-1.6.2 Successfully installed rubyforge-1.0.2 7 gems installed  ( 3gems to support IE/Windows environment are not installed ) Installation done… let’s move ahead
Tweaks/Tips While working on Linux platform need to specify require “rubygems” at the top of test case ff = FireWatir::Firefox.new Start firefox in jssh mode For Windows: Close instances of firefox (if any) Type “firefox.exe –p –jssh” in the “Run” ie = Watir::IE.new
Scope Using Watir for all web applications Integrate it with Automation/Building process
References Watir Wikipedia:  http:// en.wikipedia.org/wiki/Watir   Watir main site:  http:// wiki.openqa.org /display/WTR/   Watir user guide:  wtr.rubyforge.org/watir_user_guide.html Watir API:  wtr.rubyforge.org/rdoc/index.html Mailing List:  rubyforge.org/mailman/listinfo/wtr -general Project site:  http://wiki.openqa.org/display/WTR/ User Contributions/examples:  http://wiki.openqa.org/display/WTR/Contributions Watir FAQ:  http://wiki.openqa.org/display/WTR/FAQ Watir Recorder http://www.hanselman.com/blog/IntroducingWatirMakerRecordingForRubybasedWatir.aspx   http://www.hanselman.com/blog/NewReleaseOfWatirMakerNowWatirRecorder.aspx  FireWatir Source: http://code.google.com/p/firewatir/wiki/Firewatir Ruby Ruby site:  http://ruby-lang.org Ruby docs:  http://ruby-doc.org/ Ruby Quickstart:  ruby-lang.org/en/documentation/quickstart/
Thanks [email_address] www.sumanthkrishna.com

More Related Content

PPT
Keyword Driven Framework using WATIR
PPT
What you can do In WatiR
PPT
Introduction To Ruby Watir (Web Application Testing In Ruby)
PDF
watir-webdriver
PPT
Automated Testing With Watir
DOC
Selenium Automation Using Ruby
PDF
Introduction to Selenium and Ruby
PPTX
Web driver training
Keyword Driven Framework using WATIR
What you can do In WatiR
Introduction To Ruby Watir (Web Application Testing In Ruby)
watir-webdriver
Automated Testing With Watir
Selenium Automation Using Ruby
Introduction to Selenium and Ruby
Web driver training

What's hot (20)

PDF
Join the darkside: Selenium testing with Nightwatch.js
PDF
Selenium webdriver
PDF
Selenium - The page object pattern
PDF
Selenium bootcamp slides
PDF
High Performance JavaScript 2011
PDF
Selenium Tips & Tricks - StarWest 2015
PPTX
Browser Automated Testing Frameworks - Nightwatch.js
PDF
Unlocking the Magical Powers of WP_Query
PDF
Nightwatch at Tilt
PDF
Automation Testing using Selenium Webdriver
KEY
WordPress APIs
PPTX
Automated Smoke Tests with Protractor
PDF
Automation Abstraction Layers: Page Objects and Beyond
PDF
Selenium Overview
PDF
Selenium Best Practices with Jason Huggins
PDF
How To Use Selenium Successfully
PPTX
Angular UI Testing with Protractor
PDF
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
PDF
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
PDF
How to Use Selenium, Successfully
Join the darkside: Selenium testing with Nightwatch.js
Selenium webdriver
Selenium - The page object pattern
Selenium bootcamp slides
High Performance JavaScript 2011
Selenium Tips & Tricks - StarWest 2015
Browser Automated Testing Frameworks - Nightwatch.js
Unlocking the Magical Powers of WP_Query
Nightwatch at Tilt
Automation Testing using Selenium Webdriver
WordPress APIs
Automated Smoke Tests with Protractor
Automation Abstraction Layers: Page Objects and Beyond
Selenium Overview
Selenium Best Practices with Jason Huggins
How To Use Selenium Successfully
Angular UI Testing with Protractor
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
How to Use Selenium, Successfully
Ad

Similar to Watir Presentation Sumanth Krishna. A (20)

PDF
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
PPT
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...
PPT
No Va Taig April 7 2010
ODP
RichFaces - Testing on Mobile Devices
PPT
Testing Java Web Apps With Selenium
PPT
Selenium
PPT
Pragmatic Parallels: Java and JavaScript
PPTX
Calabash-android
PPT
10071756.ppt
PPT
selenium.ppt
PPT
selenium.ppt
PPT
selenium.ppt
PPT
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
PPT
Functional Testing Swing Applications with Frankenstein
PDF
Selenium Introduction by Sandeep Sharda
PPTX
Java Web Security Class
PPTX
Mastering Test Automation: How To Use Selenium Successfully
PPT
Selenium
PDF
End to-end testing from rookie to pro
PPT
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...
No Va Taig April 7 2010
RichFaces - Testing on Mobile Devices
Testing Java Web Apps With Selenium
Selenium
Pragmatic Parallels: Java and JavaScript
Calabash-android
10071756.ppt
selenium.ppt
selenium.ppt
selenium.ppt
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Functional Testing Swing Applications with Frankenstein
Selenium Introduction by Sandeep Sharda
Java Web Security Class
Mastering Test Automation: How To Use Selenium Successfully
Selenium
End to-end testing from rookie to pro
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Ad

More from Sumanth krishna (13)

PPTX
Scope demystified - AngularJS
PPTX
Services Factory Provider Value Constant - AngularJS
DOCX
Ruby Interview Questions
PPT
Jasmine - A BDD test framework for JavaScript
PPT
Ruby on Rails industry trends
PDF
Introducing Ruby/MVC/RoR
PPS
Life Pencil And U
PDF
Ro R Based Social Networking Apps Compared
PPS
Put The Glass Down
PPS
New Rabbit Tortoise Story
PPT
RoR relevance to startups Session @ Barcamp5 - Sumanth Krishna
PDF
Cookie - story
PPT
How Brain Works against in identifying colors?
Scope demystified - AngularJS
Services Factory Provider Value Constant - AngularJS
Ruby Interview Questions
Jasmine - A BDD test framework for JavaScript
Ruby on Rails industry trends
Introducing Ruby/MVC/RoR
Life Pencil And U
Ro R Based Social Networking Apps Compared
Put The Glass Down
New Rabbit Tortoise Story
RoR relevance to startups Session @ Barcamp5 - Sumanth Krishna
Cookie - story
How Brain Works against in identifying colors?

Recently uploaded (20)

PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Encapsulation theory and applications.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Big Data Technologies - Introduction.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Empathic Computing: Creating Shared Understanding
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Cloud computing and distributed systems.
PPTX
A Presentation on Artificial Intelligence
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Machine learning based COVID-19 study performance prediction
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Approach and Philosophy of On baking technology
NewMind AI Monthly Chronicles - July 2025
Encapsulation theory and applications.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Big Data Technologies - Introduction.pptx
Unlocking AI with Model Context Protocol (MCP)
“AI and Expert System Decision Support & Business Intelligence Systems”
Empathic Computing: Creating Shared Understanding
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Understanding_Digital_Forensics_Presentation.pptx
Cloud computing and distributed systems.
A Presentation on Artificial Intelligence
Reach Out and Touch Someone: Haptics and Empathic Computing
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Machine learning based COVID-19 study performance prediction
Spectral efficient network and resource selection model in 5G networks
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Approach and Philosophy of On baking technology

Watir Presentation Sumanth Krishna. A

  • 1. W eb A pplication T est I n R uby Sumanth Krishna. A www.sumanthkrishna.com
  • 2. Agenda Introducing the topic Discussion on Testing frameworks/tools and it’s necessity Ruby Installations Architecture Testcases Scope
  • 3. TAG CLOUD ruby Apache Nginx assertions install webserver FireWatir temp- user WATIR goto html DOM web-applications opensource tests Assertions get_string firefox-addon click hudson SVN COM open-source IE gems open-QA ruby regression loadrunner mercury automatio deployment browers tools WATIR html DOM recorder telnet
  • 4. Prerequisites Can you believe you really don’t need any special skills to implement this!
  • 5. What is WATIR? open-source functional testing tool for web-applications Simulate the user actions (filling/submitting forms…) Drives Internet Explorer browser FireWatir – for FireFox Ruby based Various assertions (content-based) Connects to databases Reading data files Exporting data (xml/html/excel…)
  • 6. Why use WATIR? Free Powerful Simple (easy to use and learn) Excellent Support Strongest Presence Watir/Watin/Watij [ W eb A pplication T esting I n R uby/. N ET/ J ava ] Huge resource of supporting tools – Firewatir, Watir Recorder ++, Wet, Cubictest, Visual Studio
  • 7. 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.( underwork )
  • 8. IE-WATIR Web Application Automation Interface Use the OLE/COM Automation interface to Internet Explorer IE Watir/Ruby DOM
  • 9. FF-FireWATIR Automation Interface FF FireWatir/Ruby DOM Web Application JSSh
  • 10. Browser Support IE COM Test Script Component 1 FF JSSH Apple Events V8 Debugger Dragonfly Component 2 Component 3 Component 4 Watir API
  • 11. Installing: Windows Install Ruby: Use the Ruby one-click installer for windows Install the latest gem watir (ruby packages are called gems) gem install watir And you find the following gems installing… Successfully installed xml-simple-1.0.11 Successfully installed s4t-utils-1.0.4 Successfully installed builder-2.1.2 Successfully installed user-choices-1.1.6 Successfully installed commonwatir-1.6.2 Successfully installed firewatir-1.6.2 ( to support Firefox ) Successfully installed watir-1.6.2 Successfully installed win32-api-1.3.0-x86-mswin32-60 Successfully installed windows-api-0.3.0 Successfully installed rubyforge-1.0.2 10 gems installed Installation done… let’s move ahead
  • 12. What Next? Since we are here to test the web-application Navigate the browser? Find elements on the page? Interact with elements on the page? Check output on the page? Create and use Methods? Create formal test cases?
  • 13. Step by Step Navigate to the browser #Always Load the Watir library at the top of your script require ‘watir’ Start IE and navigate to a given/different URL IE = Watir::IE.start(‘http://www.qvnatel.com’) IE.goto(“http://free-opensource.qvantel.net/mediawiki//index.php/Main_Page ”) IE.close
  • 14. Finding <HTML> Elements IE.frame( how, what ) Frame And many, many more (div, label, image, etc…)… IE.form( how, what ) Form IE.link( how, what ) HyperLink IE.radio( how, what ) RadioButton IE.checkbox( how, what ) CheckBox IE.select_list( how, what ) DropDownList IE.button( how, what ) Button IE.text_field( how, what ) TextBox
  • 15. Interacting with Elements #Set the text field (or text area) specified name specified value. ie.text_field( :name ,'name').set('value') #Sets the select with to the specified value ie.select_list( :name ,'name').select('value') #Click the button with the specified value (label) ie.button( :value ,'value').click #Clicks the link matching 'text' ie.link( :text ,'text').click #Accessing elements in a &quot;frame&quot; or &quot;iframe&quot; ie.frame( :name ,&quot;someFrame&quot;).text_field( :name ,'name').set('value')
  • 16. Closer view browser.button( :value , &quot;Click Me&quot;).click [Variable] . [method] (: [element] , “ [unique identifier] ” . [method]
  • 17. Checking Output #Get the title of the page ie.title #Get all the text displayed on the page ie.text #Get all the HTML in the body of the page ie.html #Return true if ‘text’ is displayed on the page ie.contains_text('text')
  • 18.  
  • 19. Ruby advantage Since WATIR is ruby based web application testing framework, we can customize the script according to our needs. Taking Ruby’s Object Oriented concepts, create more dynamic/customized scripts Use classes & methods effectively Access even the database to validate the data
  • 21. Methods #Here is an example method for logging into a web application. Its two parameters are a user and password (both of which have defaults). It returns an instance of IE def login(user=“test_admin”,password = “Password123”) ie=Watir::IE.start(‘http://someURL.com/login’) ie.text_field(:name,/user/i).set(user) ie.text_field(:name,/password/i).set(password) ie.button(:value,/login/i).click return ie end #Now we can easily login with the default user.. ie = login #or with a unique user ie = login(“Fred”,”flinstone”)
  • 22. Full Fledge Test Case require 'test/unit' #includes Ruby's test case functionality require ‘ util ’ #Assuming our login method is saved in util.rb #Test cases are contained within classes which extend Ruby’s base test case class class MyTest < Test::Unit::TestCase def setup #Optional, will be run before each test method. @ie = login() #call our login function. end def test_some_link #Test methods must begin with &quot;test_“ @ie.link(:text,”some_link”).click #click on some link #verify that the proper page loaded assert(@ie.contains_text(“My Some Link Page”)) end def teardown #Optional, will be run after each test method. @ie.close end end
  • 23. Installing: Ubuntu Install Ruby: sudo apt-get install ruby Install the latest gem firewatir (ruby packages are called gems) sudo gem install firewatir And you find the following gems installing… Successfully installed xml-simple-1.0.11 Successfully installed s4t-utils-1.0.4 Successfully installed builder-2.1.2 Successfully installed user-choices-1.1.6 Successfully installed commonwatir-1.6.2 Successfully installed firewatir-1.6.2 Successfully installed rubyforge-1.0.2 7 gems installed ( 3gems to support IE/Windows environment are not installed ) Installation done… let’s move ahead
  • 24. Tweaks/Tips While working on Linux platform need to specify require “rubygems” at the top of test case ff = FireWatir::Firefox.new Start firefox in jssh mode For Windows: Close instances of firefox (if any) Type “firefox.exe –p –jssh” in the “Run” ie = Watir::IE.new
  • 25. Scope Using Watir for all web applications Integrate it with Automation/Building process
  • 26. References Watir Wikipedia: http:// en.wikipedia.org/wiki/Watir Watir main site: http:// wiki.openqa.org /display/WTR/ Watir user guide: wtr.rubyforge.org/watir_user_guide.html Watir API: wtr.rubyforge.org/rdoc/index.html Mailing List: rubyforge.org/mailman/listinfo/wtr -general Project site: http://wiki.openqa.org/display/WTR/ User Contributions/examples: http://wiki.openqa.org/display/WTR/Contributions Watir FAQ: http://wiki.openqa.org/display/WTR/FAQ Watir Recorder http://www.hanselman.com/blog/IntroducingWatirMakerRecordingForRubybasedWatir.aspx http://www.hanselman.com/blog/NewReleaseOfWatirMakerNowWatirRecorder.aspx FireWatir Source: http://code.google.com/p/firewatir/wiki/Firewatir Ruby Ruby site: http://ruby-lang.org Ruby docs: http://ruby-doc.org/ Ruby Quickstart: ruby-lang.org/en/documentation/quickstart/