使用watir为下拉列表获取未定义的方法`set'

时间:2012-07-12 20:59:18

标签: watir

require 'watir'  

ie = Watir::Browser.new  
ie.goto "http://www.wallpapers.com/windows/Wallpapers/Animals/Dogs"  


ie.select(:id, "ctl00_CPH1_ctl00_ddlSortExpression").flash   
ie.select(:id, "ctl00_CPH1_ctl00_ddlSortExpression").set("Newest")  


C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/element.rb:433:in `method_missing': undefined method `set' for #<Watir::SelectList:0x31be0b8> (NoMethodError)
        from sample.rb:9:in `<main>'

也尝试了同样的结果:

ie.select(:id, "ctl00_CPH1_ctl00_ddlSortExpression").to_subtype.set("Newest") 

1 个答案:

答案 0 :(得分:5)

改为使用.select()

ie.select(:id, "ctl00_CPH1_ctl00_ddlSortExpression").select("Newest")  

在Watir 3.0中,选择列表不再存在.set()。不确定它是否是故障或故意删除。