Professional Documents
Culture Documents
What is Watir?
Now supports IE, Firefox, Safari, Google Chrome and Opera. As well headless browser support using HtmlUnit through Celerity and Schnell.
Is not?
Watir is not a record/playback tool. However, there are several recorders out there WatirMaker Watir WebRecorder Webmetrics RIA Script Recorder 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. Doesnt test Flash or Applets or Microsoft Silverlight.
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 Get the report file
Watir Architecture
IE COM
FF JSSH
Apple Events
V8 Debugger
Dragonfly
WATIR API
Component 1
Component 2
Component 3
Component 4
Test Script
Ruby advantage
Since WATIR is ruby based web application testing framework, we can customize the script according to our needs. Taking Rubys Object Oriented concepts, create more dynamic/customized scripts Use classes & methods effectively Access even the database to validate the data
Install on Mac
As Watir is cross platform, it can be installed in Windows/Mac/Linus. We are showing mac steps here 1. Install Ruby 1.8.7 2. Install RubyGems 3. Install OSX GCC or Xcode 4. Install Safari Watir 1) go to command window 2) sudo gem install safariwatir no-ri no-rdrc
5. Install watir-webdriver
6. For FireFox, Chrome and Opera some custome component needs to be installed.
Using Watir
Reference the Watir using the require keyword and start coding
require "watir-webdriver" browser = Watir::Browser.new :chrome browser.goto "http://bit.ly/watir-example" browser.text_field(:name => 'entry.0.single').set 'Watir' browser.close
Use View Source Firebug in firefox, or IE toolbar or inspect element in chrome. USE IRB
Closer view
WATIR Examples
ie.link(:id, lnk1).click ie.button(:id, btn1).click ie.link(:name, lnk1).exists? ie.contains_text(Welcome) wait_until {@browser.contains_text Edit"}
WATIR can find elements by id, name, text, link, XPath, etc WATIR uses the OLE/COM automation interface to control the browser.
def test_search browser = Watir::Browser.new browser.goto("http://www.google.com/ncr") browser.text_field(:name, "q").set("pickaxe") browser.button(:value, "Google Search").click assert(browser.text.include?("Programming Ruby: The Pragmatic Programmer's Guide")) end
end
WATIR Alternatives
WatiN.(.NET Framework
Watij (Java) Win-32-Watir, Perl Gambit Commercial Products Compuware TestPartner Usually based on record-playback techniques Selenium Similar open source browser automation framework.
What Next?
Watir+Selenium+WebDriver
Watir with a regression server for continuous regression testing Organizations planning to use automated testing are adopting watir. Watir is a keypart of facebook engineering. They customized it for own purpose. WebDriver with watir
References
Watir Wikipedia: http://en.wikipedia.org/wiki/Watir
Questions?
Thank You!!