#26 ✓resolved

allow clicks_button by id

Reported by gaffo | October 29th, 2008 @ 12:48 AM

buttons are not always unique on a page, need to be able to click them by an id

Comments and changes to this ticket

  • Amos King

    Amos King October 29th, 2008 @ 06:17 PM

    I would like to once again say, 'I think this guy is on to something here.'

  • Bryan Helmkamp

    Bryan Helmkamp November 15th, 2008 @ 08:22 PM

    I think this is a good feature, but I'd like to implement it with a locator method instead of changing the semantics of the click_button API (as described in #25).

  • gaffo

    gaffo November 15th, 2008 @ 11:27 PM

    What does this locator syntax look like? I've seen some of it go by in commit logs but haven't understood it yet.

  • Bryan Helmkamp

    Bryan Helmkamp November 16th, 2008 @ 01:52 PM

    I've been calling the field_with_id, etc. methods "locators". So the syntax could be:

    click_button button_with_id("foo")

    Or, as you suggested:

    click_button :id => "foo"

    Now that I think about it, maybe the best would be:

    click button_with_id("foo")

    And then instead of click_link, it could be:

    click link("whatever")
  • gaffo

    gaffo November 16th, 2008 @ 03:07 PM

    That would work. Could also use:

    click button(:id => /id_7503/)
    click link(:text => "full case sensitive link text")

    But now we're really getting down to preference. I think I'd get used to typing any of them.

    I have a meet up at work on Monday for all of the guys doing ruby/rails (8-10 people) and see if they have any thoughts on it. 2 of them basically write webrat/watir/selenium tests for a living.

    On another point, this would make the click function responsible for handling missing buttons/links/areamaps and the get/post actions, whereas the locators would be solely responsible for getting a hole of the representation objects. Seems like good separation and reuse of the api.

  • gaffo

    gaffo November 16th, 2008 @ 03:12 PM

    Forgot to add, I think that this api is different enough that you need a strategy / roadmap to get people to move to the new form. What are you thinking on that?

  • gaffo

    gaffo November 16th, 2008 @ 03:19 PM

    now that I think about it, my syntax would allow :id => && :text => at the same time. I'm not sure you would want to ever finhd a button / link by both name and id. If you're going to use id, it should be unique anyway. so your locator syntax may be less ambiguous.

  • Amos King

    Amos King November 17th, 2008 @ 10:03 AM

    • Tag set to featurerequest

    What about something like this:

    click link(:content => 'Edit') click button(:id => 'foo')

    Using content makes it look more like assert_tag. This would be familiar to users that are used to testing other areas of rails. The ease of this transition would encourage users to try webrat.

  • gaffo

    gaffo November 17th, 2008 @ 02:23 PM

    Okay, after the meeting, everyone seems to like

    click(link(:attr => matcher))
    click(button(:attr => matcher))

    for link, attr and matcher are in: :id => // :id => "" :content => // :content => "" :title => // :title => "" :class => // :class => ""

    and for button: :id => // :id => "" :content => // :content => "" :title => // :title => "" :class => // :class => "" :name => // :name => "" :value => // :value => ""

  • gaffo

    gaffo November 24th, 2008 @ 08:14 PM

    so, I'd love to help work on this but not really sure what to start with. Any way you could create a roadmap or should I?

  • Bryan Helmkamp

    Bryan Helmkamp December 25th, 2008 @ 10:26 PM

    • State changed from “new” to “resolved”

    Webrat now supports clicking buttons by ID, as well as some of the other locator strategies referred to in this thread.

    Marking this as resolved, and if anyone needs specific other locators, let's track them in separate tickets.

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