Reputation: 183
Im writing a RF script for a dynamic site.. However,based on user permissions the menu tabs change/hide. I cant use xpath since the order of the tabs might change. any suggestions. CSS and Sizzle dont seem to work great since I couldnt find and id or name values being used.
Not sure if below helps
<div class="interior_nav_lv2" id="div_2_1" style="display: block;">
<a class="subNavOffHREF " href="index.cfm?view=something.sCs">Search Cardholders</a>
<a class="subNavOffHREF " href="index.cfm?view=something.lCs">List Cardholders</a>
Upvotes: 0
Views: 218
Reputation: 386210
You can use the link text as a locator if you need to click one of the links. For example:
click link Send Message
You can also explicitly include the locator strategy:
click link link=Send Message
This is all documented under the section titled "Locating or specifying elements" in the Selenium2Library documentation.
And contrary to what is stated in your question, you can use xpath. For example, this works:
click link xpath=//a[text()='Add Cardholder']
If you need to validate the links, you can use Get Webelements to get all of the links. You can then iterate over the links to save the link text. For example:
${elements}= get webelements xpath=//div[@class='interior_nav_lv2']/a
@{links}= create list
:FOR ${element} IN @{elements}
\ append to list ${links} ${element.text}
Should contain ${links} Search Cardholders
Should contain ${links} List Cardholders
Upvotes: 3