I am writing integration tests for an asp.net mvc website using Selenium Webdriver. I am using C# but answers in C# or Java would be appreciated. I have attached the html table and the generated html code.
I want to click the edit link of groupname "bcde" using webdriver. To click the link, I need the id (2138) & not group name (bcde). I have tried
driver.FindElements(By.XPath("//tr[contains(td[2], 'bcde')]/td[1]").ToList()[0])
but it gives 2137, id of abcde (alphabetically first group containing find string "bcde"). I need the id 2138 of the exact matching groupname "bcde".
<table class="table">
<tr>
<th>
Group id
</th>
<th>
Group Name
</th>
<th>
</th>
</tr>
<tr>
<td>
2137
</td>
<td>
abcde
</td>
<td>
<span><a href="/Group/Edit/2137" id="lnkGroupEdit">Edit</a> | </span>
<span> <a href="/Instrument?groupID=2137" id="lnkGroupDelete">Delete</a> | </span>
</td>
</tr>
<tr>
<td>
2138
</td>
<td>
bcde
</td>
<td>
<span><a href="/Group/Edit/2138" id="lnkGroupEdit">Edit</a> | </span>
<span> <a href="/Delete?groupID=2138" id="lnkGroupDelete">Delete</a> | </span>
</td>
</tr>
<tr>
<td>
2139
</td>
<td>
a bcde f
</td>
<td>
<span><a href="/Group/Edit/2139" id="lnkGroupEdit">Edit</a> | </span>
<span> <a href="/Instrument?groupID=2139" id="lnkGroupDelete">Delete</a> | </span>
</td>
</tr>
</table>