CSC/ECE 517 Fall 2014/ch1a 19 mx: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 4: Line 4:


== Introduction==
== Introduction==
Watir('''W'''eb '''A'''pplication '''T'''est '''i'''n '''R'''uby), pronounced water, is an open-source (BSD) family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. It is simple and flexible. It drives Internet Explorer, Firefox, Chrome, Opera and Safari, and is available as a RubyGems gem.[4][5] Watir was primarily developed by Bret Pettichord and Paul Rogers. <ref name=Watir>{{cite web|url=http://watir.com/|work=Watir web site|accessdate=11 October 2012|title=Watir home page}}</ref><ref name=Opera>{{cite web|title=A new member in the Watir-family|url=http://www.opera.com/developer/tools/operawatir/|work=Opera Software web site|publisher=Opera Software|accessdate=11 October 2012}}</ref><ref name=Facebook>{{cite web|title=Watir to WebDriver: Unit Test Frameworks|url=https://www.facebook.com/notes/facebook-engineering/watir-to-webdriver-unit-test-frameworks/10150314152278920|work=Facebook Engineering's Notes|publisher=Facebook|accessdate=11 October 2012}}</ref><ref name="Agile Testing">{{cite book|last=Crispin, Gregory|title=Agile Testing: A Practical Guide for Testers and Agile Teams|year=2008|publisher=Addison-Wesley|isbn=9780321534460|pages=172|url=http://books.google.com/books?id=68_lhPvoKS8C}}</ref>  It drives [[Internet Explorer]], [[Mozilla Firefox|Firefox]], [[Google Chrome|Chrome]], [[Opera (web browser)|Opera]] and [[Safari (web browser)|Safari]], and is available as a [[RubyGems]] gem.
Watir('''W'''eb '''A'''pplication '''T'''est '''i'''n '''R'''uby), pronounced water, is an open-source (BSD) family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. It is simple and flexible.[4][5] Watir was primarily developed by Bret Pettichord and Paul Rogers. <ref name=Watir>{{cite web|url=http://watir.com/|work=Watir web site|accessdate=11 October 2012|title=Watir home page}}</ref><ref name=Opera>{{cite web|title=A new member in the Watir-family|url=http://www.opera.com/developer/tools/operawatir/|work=Opera Software web site|publisher=Opera Software|accessdate=11 October 2012}}</ref><ref name=Facebook>{{cite web|title=Watir to WebDriver: Unit Test Frameworks|url=https://www.facebook.com/notes/facebook-engineering/watir-to-webdriver-unit-test-frameworks/10150314152278920|work=Facebook Engineering's Notes|publisher=Facebook|accessdate=11 October 2012}}</ref><ref name="Agile Testing">{{cite book|last=Crispin, Gregory|title=Agile Testing: A Practical Guide for Testers and Agile Teams|year=2008|publisher=Addison-Wesley|isbn=9780321534460|pages=172|url=http://books.google.com/books?id=68_lhPvoKS8C}}</ref>  It drives [[Internet Explorer]], [[Mozilla Firefox|Firefox]], [[Google Chrome|Chrome]], [[Opera (web browser)|Opera]] and [[Safari (web browser)|Safari]], and is available as a [[RubyGems]] gem.


== Overview ==
== Overview ==

Revision as of 01:49, 14 September 2014

Watir


Introduction

Watir(Web Application Test in Ruby), pronounced water, is an open-source (BSD) family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. It is simple and flexible.[4][5] Watir was primarily developed by Bret Pettichord and Paul Rogers. <ref name=Watir></ref><ref name=Opera></ref><ref name=Facebook></ref><ref name="Agile Testing"></ref> It drives Internet Explorer, Firefox, Chrome, Opera and Safari, and is available as a RubyGems gem.

Overview

Web Application Testing

Why Ruby

Installation

Make It Run

All examples are designed to work on the live Watir demo form: http://bit.ly/watir-example.

Run in .rb

You can require Ruby Watir gem first via the -rubygems command line option or by using the RUBYOPT environment variable. You can also require it manually in your script: require 'rubygems'

Including Watir gem to drive Internet Explorer on Windows require 'watir'

Including Watir-WebDriver gem to drive Firefox/Chrome on Windows/Mac/Linux require 'watir-webdriver'

Starting a new browser & and going to our site browser = Watir::Browser.new browser.goto 'http://bit.ly/watir-example'

Setting a text field

browser.text_field(:name => 'entry.0.single').set 'Watir'

Setting a multi-line text box browser.text_field(:name => 'entry.1.single').set "I come here from Australia. \n The weather is great here."

Setting and clearing a radio button browser.radio(:value => 'Watir').set browser.radio(:value => 'Watir').clear

Setting and clearing check boxes browser.checkbox(:value => 'Ruby').set browser.checkbox(:value => 'Python').set browser.checkbox(:value => 'Python').clear

Clicking a button browser.button(:name => 'logon').click

Clearing, getting and selecting selection list values browser.select_list(:name => 'entry.6.single').clear puts browser.select_list(:name => 'entry.6.single').options browser.select_list(:name => 'entry.6.single').select 'Chrome'

Clicking a button browser.button(:name => 'submit').click

Checking for text in a page puts browser.text.include? 'Your response has been recorded.'

Checking the title of a page puts browser.title == 'Thanks!'

Run in other framworks

Comparison with Other Tools

Reference