#195 ✓wontfix
diabolo

click_link using title and classes

Reported by diabolo | March 13th, 2009 @ 12:06 PM | in 0.4.5

current gem 0.4.2 doesn't support title and classes when doing click link.

i've done a fork which fixes this

Comments and changes to this ticket

  • diabolo

    diabolo March 13th, 2009 @ 12:10 PM

    actual commits are listed below

    first adds tests for title

    http://github.com/diabolo/webrat...

    second adds functionality for classes

    http://github.com/diabolo/webrat...

  • diabolo

    diabolo April 21st, 2009 @ 01:27 PM

    • Assigned user set to “Bryan Helmkamp”

    This has been submitted for about a month now. Is there any reason its being ignored?

  • gaffo

    gaffo April 22nd, 2009 @ 01:22 PM

    • Tag changed from click_link to click_link, patch, pull, verify
    • State changed from “new” to “open”

    first branch looks good.

  • gaffo

    gaffo April 22nd, 2009 @ 01:36 PM

    2nd branch looks fine as well. The question is does it align with the api for the other modes.

  • Bryan Helmkamp

    Bryan Helmkamp April 22nd, 2009 @ 04:42 PM

    • State changed from “open” to “wontfix”

    Hey Andew,

    Sorry for the delay. I do not want to expand the current click_link API to support more location strategies implicitly, but I'd like to support this with another API.

    Here's what I'm thinking:

    
    click_link link_with_css(".class_name")
    

    Not a huge fan of the duplication of "link" but that's the best I've got so far.

    Can you please open a ticket about adding a method to lookup a link by CSS if that's useful to you, so we can track it separately? Thanks.

    Cheers,

    -Bryan

  • diabolo

    diabolo April 23rd, 2009 @ 11:37 AM

    Couldn't you accept these patches and then decide to refactor the api afterwards? The patches do work, have been tested and are useful (been used in our current project for a while). In the meantime the new api doesn't exist yet. When you decide what this new api is I'm sure you can then refactor to get things just how you want them

  • Lee Hambley

    Lee Hambley April 23rd, 2009 @ 11:40 AM

    I can't see the case for not including the patch, although the prospect of reliable CSS selectors to do this sort of work are exciting, but it is leaving us all hanging a bit those of us who have had to fork webrat, and can't benefit from master changes without a load of grief keeping up to date could really use this patch.

    On what grounds are you not thinking of including this in the main distribution?

  • Lee Hambley

    Lee Hambley April 23rd, 2009 @ 11:45 AM

    Also it strikes me that link_with_css is a silly name, why not something like the following

    
    
    click_link 'Shopping Cart' # Behaves as it does presently
    
    click_link :class => 'shopping_cart'  # Class Selector `.shopping_cart`
    click_link :class => '.shopping_cart' # As Above.
    
    click_link :id => 'shopping_cart_1'  # ID Selector
    click_link :id => '#shopping_cart_1' # ID Selector
    
    click_link :href => '/cart/item/\d+' # Select anything that matches that pattern
    
    

    Just a thought, that is what my implementation went...

  • Rob Aldred

    Rob Aldred April 23rd, 2009 @ 01:15 PM

    I like lee.hambley's suggestion, but maybe a better way would be using css selectors click_link '.shopping_cart' click_link '#shopping_cart_1' click_link 'a[href=/cart/item]'

    click_link link_with_css does not read right :(

  • gaffo

    gaffo April 23rd, 2009 @ 01:53 PM

    One of the things we want to avoid is having to deprecate apis. Pulling in the patch as it is would require us to do so. Having a stable and standard api for webrat across all of the drivers and application frameworks has been a major goal for the last year.

  • gaffo

    gaffo April 23rd, 2009 @ 01:59 PM

    • Milestone set to 0.4.5
  • gaffo

    gaffo April 23rd, 2009 @ 01:59 PM

    changed the milestone just for the tests. no problem changing it back if this is confusing.

  • Morgan Christiansson

    Morgan Christiansson July 20th, 2009 @ 08:46 AM

    +1 for Rob Aldreds suggestion to use CSS selectors.

    click_link ".shopping_cart"
    click_link ".shopping_cart input[type='submit']"
    click_link "a[href^='/cart']"
    

    This is very similair to the jquery API:

    $(".shopping_cart input[type='submit']").click();
    $("a[href^='/cart']")
    

    Very flexible and fully backwards compatible.

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

Pages