Dogman
-
2008-06-25
ruby+Watir web测试 - [测试]
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://zlfoxy.blogbus.com/logs/23543979.html
原文详见: http://wiki.openqa.org/display/WTR/Example+Test+Case
#-------------------------------------------------------------#
# Demo test for the Watir controller.
#
# Simple Google test written by Jonathan Kohl 10/10/04.
# Purpose: to demonstrate the following Watir functionality:
# * entering text into a text field,
# * clicking a button,
# * checking to see if a page contains text.
# Test will search Google for the "pickaxe" Ruby book.
#-------------------------------------------------------------#
# the Watir controller
require "watir"
# set a variable
test_site = "http://www.google.com"
#open the IE browser
ie = Watir::IE.new
# print some comments
puts "Beginning of test: Google search."
puts " Step 1: go to the test site: " + test_site
ie.goto test_site
puts " Step 2: enter 'pickaxe' in the search text field."
ie.text_field(:name, "q").set "pickaxe" # "q" is the name of the search field
puts " Step 3: click the 'Google Search' button."
ie.button(:name, "btnG").click # "btnG" is the name of the Search button
puts " Expected Result:"
puts " A Google page with results should be shown. 'Programming Ruby' should be high on the list."
puts " Actual Result:"
if ie.text.include? "Programming Ruby"
puts " Test Passed. Found the test string: 'Programming Ruby'. Actual Results match Expected Results."
else
puts " Test Failed! Could not find: 'Programming Ruby'."
end
puts "End of test: Google search."随机文章:
将RAW整合到Eclipse 2008-06-25安装Ruby和Watir 2008-06-25Junit in action笔记 2009-06-04JMeter用户手册第7节(建立一个数据库测试计划) 2008-03-10JMeter第6节(建立一个高级的测试计划) 2008-03-10
收藏到:Del.icio.us








评论