Watir ????? Ruby ?????Web ?????????????????????????????????????????????????????????????????????????
?? Watir ??????????????? FAQ ?????????????????????????????????????????????????
1. ????
????????????? Watir ?????????????????? Watir ??????? Google ???????????????????????????????????
require 'watir' # the watir controller
# open the IE browser
ie = Watir::IE.new
# Step 1: go to the test site: http://www.google.com
ie.goto (http://www.google.com)
# Step 2: enter 'pickaxe' in the search text field
ie.text_field(:name, "q").set("pickaxe") # q is the name of the search field
# Step 3: click the 'Google Search' button
ie.button(:name, "btnG").click # "btnG" is the name of the Search button
# Actual Result: Check that the 'Programming Ruby' link appears on the results page
if ie.contains_text("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
# End of test: Google search
???????????? Google ??????? Google ???????????“pickaxe”??????????“Google ??”????????????????????“Programming Ruby”????????????? puts ?????????????????“#”??????????????????????????????????????????
2. ??????
Ruby : ????? Ruby ???????? Ruby ????????????? Ruby??????????????????????Ruby 1.8.2-14 ?????????????Ruby 1.8.2-15 Stable Release?
Watir : ??????????????? Watir 1.4 ????.zip ?????????? install.rb ???????????????? Watir ??????????????????????
WINDOWS 2000 ? XP + IE 5.5 ???? : ?? Watir ???????????????????
3. ???????
???????????????????????????????????——?? Ruby ???????????????????????????????????????????????????? VBScript ?????????? Watir ?????????????? Web ????? HTML ?????????????????? Web ?????????? Web ???????——?????????????????? Mozilla Firefox ????“DOM ???”???? Mozilla Firefox“??”??????????????? Mozilla Firefox ????
????????????????????????
4. ?????
?????????Watir ???????????????????????????????????????Watir ???????? QTP ?? Rational ?????????????
5. ?????????????
Watir ???????? Web ?????????????? Hyperlinks ????Checkboxes ???????Radio Buttons ?????????????????????????????????? Frame ???????????????????????????????????????????????????????????? Watir ?????
6. ????
?????? Ruby ?????????????? Watir ????????????????????????????????????????????????????????????????????????????
7. ????
Watir ???http://wtr.rubyforge.org/
Ruby?????http://www.ruby-cn.org/doc.html
Ruby???http://ruby-lang.org/en/
????????Watir ??????FAQ????????????????? Watir ???? sample test ? User’s Guide ??????? Watir ???? Web ????????????????????? Technical Doc ??????? Watir ?????????????????????email?????????