Reputation: 13
I have read many online threads and tried many XPath combinations, but it seems that whatever I did, I'm still not able to find my custom XPath for my element. Here is my HTML code, and I need to find the XPath for the highlighted/stared item.
TIA
<div style="display: -moz-box;">
<label for="employeeSel">Select Employees</label>
<table>
<tbody>
<tr>
<td>
<select id="employeeSel" multiple name="employeeSel" size="10" style="min-width:120px; padding-left:0.4em; padding-right:0.4em">...</select>
</td>
<td valign="top">
**<a onclick="selectAll('employeeSel',true)">Select All</a>**
</td>
</tr>
</tbody>
</table>
Upvotes: 1
Views: 1113
Reputation: 29022
To select the a
element, use the following XPath-1.0 expression:
//div[contains(@style,'display:')]/table/tbody/tr/td[@valign='top'][preceding-sibling::td[select/@id='employeeSel']]/a
A second approach is this:
//div[contains(@style,'display:')]/table/tbody/tr/td[select/@id='employeeSel']/following-sibling::td[@valign='top']/a
Both expression should return the same element a
.
Upvotes: 1