Watir官网案例的问题(一)

2012-03-28  潘文杰 

对着官网的标准例子做了一遍(http://watir.com/examples/),发现watir的几个问题:
1、支持IE不支持FF的几个方法:
browser.radio(:value => 'Watir').clear
browser.select_list(:name => 'entry.6.single').clear
browser.select_list(:name => 'entry.6.single').clearSelection

2、logon在页面上不存在。
------------------------------------华丽的分割线-----------------------------------
#修改后的代码如下:
#Including Watir-WebDriver gem to drive Firefox/Chrome on Windows/Mac/Linux
#require 'watir-webdriver'
require 'watir'
#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 #something wrong with ff
#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  #something wrong - no such name
#Clearing, getting and selecting selection list values
puts browser.select_list(:name => 'entry.6.single').options
browser.select_list(:name => 'entry.6.single').select 'Chrome'
browser.select_list(:name => 'entry.6.single').clear  # something wrong  with ff
browser.select_list(:name => 'entry.6.single').clearSelection  # something wrong with ff
#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!'
#There are several examples from the Watir community
370°/3706 人阅读/0 条评论 发表评论

登录 后发表评论