Consider this irb session:
irb(main):001:0> require 'Watir'
=> true
irb(main):002:0> include Watir
=> Object
irb(main):003:0> ie = IE::start_process('www.google.com')
=> #<Watir::IE:0x2c7d86c ....>
irb(main):006:0> ie.div(:id, 'gbar').id
=> "gbar"
irb(main):007:0> ie.div(:id=>'gbar').id
=> "gbar"
irb(main):008:0> ie.text_field(:name, 'q').id
=> ""
irb(main):009:0> ie.text_field(:name, 'q').name
=> "q"
irb(main):010:0> ie.text_field(:name=>'q').name
TypeError: {:name=>"q"} is not a symbol
irb(main):011:0>
Accessing an input element with a hash fails. Input elements in Watir currently only support a single search item and this is the cause of the confusion.
This patch will solve the problem:
require 'watir'
module Watir::Container
alias :old_locate_input_element :locate_input_element
#form elements do not allow the hash syntax for how/what.
#this change here allows it for single element hashes by
#just converting the hash into a distinct how and what and then
#passing it on
def locate_input_element(how, what, types, value=nil)
how, what = *how.to_a[0] if (how.kind_of? Hash) && (how.length == 1)
old_locate_input_element(how, what, types, value)
end
end
All it does is convert a hash into the multiple args (how and what) that the input element look up requires. It doesn't do anything to allow multiple look up values for input elements.
Update: Turns out this this is a know issue.
No comments:
Post a Comment