#15 awaiting-merge
Deleted User

click_button an image button should send X/Y coordinates as params

Reported by Deleted User | 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

  • Deleted User

    Deleted User September 5th, 2008 @ 12:40 PM

    Ah. This looks like a dupe of #8.

  • Deleted User

    Deleted User 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"

  • Deleted User

    Deleted User 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"
    
  • Deleted User

    Deleted User 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
    
  • Deleted User

    Deleted User 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

    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

    gaffo January 6th, 2009 @ 07:57 PM

    • Tag set to featurerequest, patch

    Brynary, what's the state on this one.

  • Mike Burns

    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

    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.

  • Deleted User

    Deleted User 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...

  • gaffo

    gaffo May 7th, 2009 @ 01:04 PM

    • State changed from “new” to “awaiting-merge”

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

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.

Shared Ticket Bins

People watching this ticket

Attachments

Pages