On Tuesday, May 1, 2012 12:03:07 PM UTC-7, mndude wrote: > > > 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> >
You are looking at an old version of the repository, things have moved, you want https://github.com/watir/watir-webdriver I don't know what the 'bubble' parameter was doing, but it has been removed in the current code (which has that definition on line 246 as indicated by your error. def fire_event(event_name) assert_exists event_name = event_name.to_s.sub(/^on/, '').downcase execute_atom :fireEvent, @element, event_name end The events are a standard javascript thing, within the html that's where the names are defined etc. See : http://www.w3schools.com/tags/ref_eventattributes.asp for a list of the event names defined when HTML4 came out. 'true' is a string, the code fragment you provided below shows a Boolean being used, e.g. true without quotes. however since that second parameter is no longer in the current code it's pretty much not relevant either way The error means that the code on the line indicated (which you did not look at) only accepts a single parameter and you provided two parameters, which makes perfect sense if you are looking at the code that is executing on your system and not an older version of the code. (Where did you find that by the way, as I think we may need to update some links if there is something pointing you to the old watir-webdriver that started out under Jarib's github and has since moved under Watir to put everything in one place going forward. > > > > 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>' >>> >> On Tuesday, May 1, 2012 12:03:07 PM UTC-7, mndude wrote: > > > 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]
