- (Object) fire_event(event_name, bubble = false)
[Hide source]
134 135 136 137 138 |
# File 'lib/watir-webdriver/elements/element.rb', line 134 def fire_event(event_name, bubble = false) assert_exists event_name = event_name.to_s.sub(/^on/, '') browserbot('triggerEvent', @element, event_name, bubble) end |
The snippet is direct from that API doc and seems to imply that I can pass 2 parameters in. What does the error "ArgumentError: wrong number of arguments (2 for 1)" mean? Is this just a bug in this API?
Once I've located a button, "button.fire_event 'click'" does work to click the button. So does 'onclick' instead of 'click'. I guess what is unclear to me is what exactly Watir's fire_event will take for the event_name parameter. Is event_name something from Watir or is it what I can see when Firebug is logging events in the Firebug Console? Or something else?
I can try to send 'onclick', 'true', but that gives the same error:
irb(main):015:0> button.fire_event 'onclick', 'true'
ArgumentError: wrong number of arguments (2 for 1)
from C:/Ruby/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.5.5/lib/watir-webdriver/elements/element.rb:246:in `fir
_event'
from (irb):15
from C:/Ruby/bin/irb:12:in `<main>'
These are the Firebug events I'm talking about.
assert_existsevent_name = event_name.to_s.sub(/^on/, '').downcaseexecute_atom :fireEvent, @element, event_nameend