Need help creating XPATH selectors which depends on the name of the element

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Need help creating XPATH selectors which depends on the name of the element

                       
Here is a snippet of source code from the application corresponding to the collapsed state of the folders.

<li class="folder collapsed" data-nodecode="RentalValues">
<p>Rental Values</p>
<ul>
</li>
<li class="folder collapsed" data-nodecode="Affordability">
<p>Affordability</p>
<ul>
</li>

The problem with the current default element xpath locator is that if few months down the line we introduce another folder on the tree it may shift the folder position up or down the tree, which would result in wrong folder being opened. Therefore can someone please help my put together an XPath which would be more robust and would not depend on the exact location of folder in the tree but rather the name of the folder which is unique?

Cheers

Shan
shanski21
I wonder if someone can help me. I have an application where user single click on folder icons to open/close it (Similar to how we navigate/explore files in windows explorer tree) - When I am recording my test in selenium IDE here is code that's generated:

click//ul[@id='analysisTree']/li[3]/p
click//ul[@id='analysisTree']/li[4]/p