click_button an image button should send X/Y coordinates as params
Reported by kwerle | September 5th, 2008 @ 12:32 PM
I have an image button in a form. There doesn't seem to be any easy? way to click it.
Comments and changes to this ticket
-

-

kwerle September 5th, 2008 @ 04:10 PM
This is somewhat resolved in the git repository. webrat is in dire need of a new release.
clicks_button on an image button fails to send some expected button data.
...Clicking that should send all the form data and "button_name.x"=>"0", "button_name.y"=>"0", "action"=>"some_action"
-

kwerle September 5th, 2008 @ 04:26 PM
This is somewhat resolved in the git repository. webrat is in dire need of a new release.
clicks_button on an image button fails to send some expected button data.
...<input alt="Alt Tag" name="button_name" src="source.gif" title="Title" type="image" /> </form> Clicking that should send all the form data and "button_name.x"=>"0", "button_name.y"=>"0", "action"=>"some_action" -

kwerle September 5th, 2008 @ 05:02 PM
ButtonField diff:
def to_param - return nil if @value.nil? - super + if @value.nil? + return_hash = {} + else + return_hash = super + end + if ! @element["src"].blank? + return_hash["#{name}.x"] = 0 + return_hash["#{name}.y"] = 0 + #value = @value.to_s.gsub('&', '%26') + #param_parser.parse_query_parameters("#{name}=#{value}") + end + return_hash end -

kwerle September 5th, 2008 @ 06:02 PM
Doh! That will do the .x.y for all image buttons in the form. It should only post for the clicked one:
def to_param - return nil if @value.nil? - super + if @value.nil? + return_hash = {} + else + return_hash = super + end + if @clicked && ! @element["src"].blank? + return_hash["#{name}.x"] = 0 + return_hash["#{name}.y"] = 0 + #value = @value.to_s.gsub('&', '%26') + #param_parser.parse_query_parameters("#{name}=#{value}") + end + return_hash end def default_value @@ -145,6 +155,7 @@ def click set(@element["value"]) unless @element["name"].blank? + @clicked = true @form.submit end -
Bryan Helmkamp October 25th, 2008 @ 05:02 PM
- → Title changed from Can't seem to clicks_button an image button to click_button an image button should send X/Y coordinates as params
-
gaffo January 6th, 2009 @ 07:57 PM
- → Tag changed from to featurerequest patch
Brynary, what's the state on this one.
-

Mike Burns January 6th, 2009 @ 08:56 PM
I've made a patch against the master branch for adding optional arguments to #click_button. This way you can do:
click_button 'button-id', :x => 5, :y => 100
-
Bryan Helmkamp January 7th, 2009 @ 12:43 PM
Is it sufficient to pass in an X/Y of 0,0 or 1,1, or is anyone doing anything that depends on the exact values?
I don't really want to add :x and :y as options that click_button takes if at all possible.
-

kwerle January 7th, 2009 @ 01:00 PM
Remember image maps!? Pretty sure they want an exact coordinate - but I've never actually used 'em.
Certainly the data is possible to extract from the form submit. I'm sure someone, somewhere wants to know exactly where the user clicked...
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Ruby Acceptance Testing for Web applications
