Forum: Ruby on Rails Selenium - using jquery locators instead of xpath

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.
Max W. (Guest)
on 2009-05-14 18:13
I'm writing some selenium tests and find myself doing stuff like this a
lot:

  @browser.click("//div[@id='four-col-bd']//div[contains(@class,
'column')]//a")

In this case i want to click on the first link in the first column in a
div that has a group of four columns in it.

I'm thinking it would be nicer to use jquery-style dom element selectors
for this sort of thing...can anyone think of a way i could lever it in
there?

BTW, in case anyone's wondering, i have been using the selenium ide to
generate test scripts but i find that the link locators tend to be too
data-specific: that is, the ide records that you clicked on a link by
saying "link=<link_html>", where link_html is the visible text in the
link.  This seems too fragile and data-dependent, that's why i'm trying
to generalise it a bit to use the page structure instead.
This topic is locked and can not be replied to.