Reputation: 1902
I have such xml:
<table>
<thead>
<tr>
<th><div class="SelectBox"></div></th>
<th tabindex="0"><div>ID</div></th>
<th><div>NAME</div></th>
<th><div>City</div></th>
</tr>
</thead>
<tbody>
<tr>
<td><div class="SelectBox"></div></td>
<td><div>id-10341</div></td>
<td><div>Anna</div></td>
<td><div>London</div></td>
</tr>
<tr>
<td><div class="SelectBox"></div></td>
<td><div>id-10249</div></td>
<td><div>Eva</div></td>
<td><div>Paris</div></td>
</tr>
</tbody>
</table>
I need to define xpath to a cell with class SelectBox
in a line containing text id-10249
I tried to use this way, but it didn’t help.
//tbody//*[contains(text(),'id-10249')]//parent::tr//div[@class='SelectBox']
Upvotes: 0
Views: 404
Reputation: 943
Here is a variant of an XPath:
//tbody/tr[td/div[contains(text(),'id-10249')]]/td/div[@class='SelectBox']
You select tr elements which satisfy the condition for contaning text in div element and than search inside this tr element for div element with a specified class.
Upvotes: 1