Selenium - using jquery locators instead of xpath


#1

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.