Reputation: 26129
I need to find a <div>
with certain content and click
it from Selenium, as so:
<tr> <td>clickAndWait</td> <td>//div[@class='gwt-Label' ***WITH CONTENT='Logout'***]</td> <td>5000</td> </tr>
Is there some way to do this? I don't want to use an absolute xpath.
Upvotes: 7
Views: 18296
Reputation: 31851
Perhaps your XPath just isn't quite doing what you think. You may need to use the string() function to concatenate all the text in a block.
For example, in TestPlan (using Selenium as backend) you would do something like this:
Click //div[@class='gwt-Label'][contains(string(),'Logout')]
Note the use of string()
Upvotes: 1
Reputation: 8223
You could also use CSS locators:
<div class="gwt-Label">This FindMe DIV</div>
Could be located using:
css=.gwt-Label:contains('FindMe')
Upvotes: 8