3
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") 
4

1 回答 1

5

改用.select()

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

在 Watir 3.0 中,.set()选择列表不再存在。不知道是bug还是故意删除。

于 2012-07-12T21:49:18.797 回答