Forum: RSpec webrat within selector

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
387fb00ef9d6d523d43018d9c81ab36b?d=identicon&s=25 Jonathan Linowes (Guest)
on 2008-10-13 19:55
(Received via mailing list)
anyone know if/how webrat can scope a clicks_link within a selector?
eg, if I have more than one "Foo" link on a page, I want to make sure
I click the one within a specific div

Tia

linoj
944f769c99deff7aa8bc3b5b93830b7a?d=identicon&s=25 Scott Taylor (Guest)
on 2008-10-13 21:38
(Received via mailing list)
On Oct 13, 2008, at 1:54 PM, Jonathan Linowes wrote:

> anyone know if/how webrat can scope a clicks_link within a selector?
> eg, if I have more than one "Foo" link on a page, I want to make
> sure I click the one within a specific div

I'm pretty sure clicks link can also take an id.  It's not the
prettiest solution (in fact, I'm sure Bryan would say webrat was
developed to *explicitly* so that you wouldn't use an id...but I
digress).

Scott
Ba051cd2587e000ef7a5f5ea5ac16129?d=identicon&s=25 Bryan Helmkamp (Guest)
on 2008-10-14 08:14
(Received via mailing list)
Jonathan,

This should work:

within "#user_43" do |scope|
  scope.click_link "Edit"
end

If you're using Rails' record identification HTML helpers, you can do
something like within('#' + dom_id(user)) to save some typing.

Scott's right that I'd recommend avoiding targeting IDs when possible,
but Webrat supports it in a few ways for cases where it's needed.

-Bryan

On Mon, Oct 13, 2008 at 3:36 PM, Scott Taylor
387fb00ef9d6d523d43018d9c81ab36b?d=identicon&s=25 Jonathan Linowes (Guest)
on 2008-10-14 08:52
(Received via mailing list)
thanks guys
yeah, my case is a step like When "I click on the $tab tab"... I want
to make sure its a link in a tab, not some other link on the page
with the same text
This topic is locked and can not be replied to.