tags:

views:

51

answers:

3

Hi

I've recorded a Test Case in Selenium IDE where I access to a newspaper and click on a certain element (a link to a blog by KEITH DUGGAN). The commands recorded are these:

open | h t t p://www.irishtimes.com/

clickAndWait | link=Sport

clickAndWait | //div[@id='content']/div[2]/div[2]/div[2]/ul/li[3]/a/span

h t t p://img180.imageshack.us/img180/8971/seleniumtest.jpg

The problem I see with this, is that if the order of the blogs displayed are changed, my Test Case won't work anymore, because instead of accessing to KEITH DUGGAN's blog it will access to a different one.

Is there a way I can tell Selenium that I want to access to KEITH DUGGAN's blog and not the third blog in a list? Basically, I want to access to an item by its text linked and not the possition (XPath)

Thanks for your time and help

}Panacea{

A: 

Take a look on selenese documentation for possible selectors.

amra
Thanks! It was very useful
Panacea
+1  A: 

You can do

xpath=//span[text()='Keith Duggan: Sideline Cut']

or

css=span:contains('Keith Duggan: Sideline Cut')

That will always find that blog

AutomatedTester
Hi AutomatedTester!Both options worked perfectly fine. How did you know about the "text()" and the "contains" options? I couldn't find them in the Selenium tutorial. Thanks for your help
Panacea
A: 

You can install and use Firebug to construct CSS identifiers. These should be position independent.

Rajat