Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium: how to find div with specific content?

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.

like image 669
Jonas Byström Avatar asked Feb 02 '10 12:02

Jonas Byström


1 Answers

You could also use CSS locators:

<div class="gwt-Label">This FindMe DIV</div>

Could be located using:

css=.gwt-Label:contains('FindMe')
like image 102
Dave Hunt Avatar answered Oct 05 '22 19:10

Dave Hunt