tags:

views:

96

answers:

1

selenium IDE gave me following xpath for string on page called "System". However this string may appear somewhere other than this place in future.

//ul[@id='idCTree_sor_ul']/li/ul/li[23]/span

how can I rewrite above xpath by spcifying text()="System" in xpath , so in future if index of that string is moved would not impact on my xpath

+1  A: 
//span[./text() = 'System']
Matthew Flaschen
Hi matthew , thanks for your quick reply. the xpath you provided producing following error:[error] locator not found: //span[./text() = 'System'], error = Error: Element //span[./text() = 'System'] not found
doneright
sorry it was my error while evaluating the xpath. Xpath you provided worked fine ...thanks
doneright
@doneright: You can't upvote (yet). Please at least accept an answer that helped you.
Tomalak
Just be aware that using the // ancestor axis can be extremely slow if your XML input is large. I understand your desire to have XPath that will work if the XML changes, but part of the design of XPath is that it is tied to the XML structure.
Peter Jacoby