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.
<https://lh6.googleusercontent.com/-XcP50cSWKrQ/T6AybM4xTyI/AAAAAAAAAJQ/T8o9K7zRxtI/s1600/5-1-2012-0002.png>
On Tuesday, May 1, 2012 11:40:58 AM UTC-5, Chuck van der Linden wrote:
>
> your snippet is from lines 134-138 in element.rb The error is
> originating on line 246
>
> also I do not think 'click' is a valid eventname I think you want
> 'onclick' (although the code internally seems to strip the 'on' off so
> that may not matter, still as a matter of form I prefer the code someone is
> reading have event names that match what any javascript etc would tend to
> be looking for, just so it makes more sense to any developer who might not
> know the watir internals and is looking at my code trying to debug a
> problem or fix his or my bugs or something)
>
> in addition to that, I'm not sure ':true' (a symbol since it starts with a
> colon) will automagically cast into a boolean, you may just want 'true'
> (sans quotes)
>
> On Tuesday, May 1, 2012 9:15:08 AM UTC-7, mndude wrote:
>>
>> Maybe because I'm new to ruby I'm reading the API docs wrong but...
>>
>> I'm looking at this page
>> http://jarib.github.com/watir-webdriver/doc/Watir/Element.html#fire_event-instance_method
>>
>> Where it says:
>>
>> - (Object <http://jarib.github.com/watir-webdriver/doc/Watir/Object.html>)
>> *fire_event*(event_name, bubble = false)
>> [Hide source<http://jarib.github.com/watir-webdriver/doc/Watir/Element.html#>
>> ]
>>
>> 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
>>
>>
>> But, if I try to execute fire_event with 2 arguments I get an error:
>>
>> irb(main):013:0> button.fire_event( 'click', :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
>>
>> `fire_event'
>> from (irb):13
>> from C:/Ruby/bin/irb:12:in `<main>'
>>
>
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]