Watir uses Ruby to work with internet explorer in windows. Watir does not work with Active X plugin components, Java applets, macromedia flash. To start with Watir, All you need is the knowledge of HTML, little programming exposure and basic concepts of Ruby. Watir is very powerful and very easy to use.
A sample test file which i made for checking mails from rediff website.
#----------------------------------------------------------------------------------#
Simple Rediffmail test written by Sunil Gupta 7/20/06
# 1) log on to mail account
# 2) check new mails
# 3) Click on a mail link
# 4) forward this mail
# 5) Logout from mail
#------------------------------------------------------------------------------------#
require 'watir' # the watir controller
# set a variable
test_site = 'http://www.rediffmail.com/cgi-bin/login.cgi'
# open the IE browser
ie = Watir::IE.new
# print some comments
puts "## Beginning of test: Rediffmail"
ie.goto(test_site)
puts " Action: entered " + test_site + " in the address bar."
puts "Step 2: Logon:" ie.text_field(:name, "login").set("admin")
ie.text_field(:name, "passwd").set("password")
ie.button(:name, "proceed").click
puts "Logged on as admin"
puts "Step 3: Check new mails" ie.link(:text, "new mails").click
sleep 6.0
puts "Step 4: Open a mail"
ie.link(:text, "NIIT").click
sleep 3.0
puts "Step 5: Forward this mail"
ie.button(:value, "Forward").click
sleep 2.0
puts "Step 6: Enter email address"
ie.text_field(:name, "To").set("admin@yahoo.com")
ie.button(:value, "Send").click
puts "Step 7: Logout"
ie.link(:text, "Logout").click
puts "Expected Result: "
if ie.contains_text("admin")
puts "Test Passed. Found the test string: 'admin'. Actual results match expected result"
else
puts "Test Failed! Could not find: 'admin'"
end
puts " "
puts "## End of test: Rediffmail"
# -end of simple Rediffmail test
To know more about Watir, You can check their home page. Watir- An automated test tool.











0 comments:
Post a Comment