Home > Net >  How we can access hyper link from table td in selenium c#
How we can access hyper link from table td in selenium c#

Time:10-05

<tr role="row" class="odd">
<td class="sorting_1">Abrar</td>
<td>1571</td>
<td>Out</td>
<td>No</td>
<td>ALL</td>
<td>Deskflex</td>
<td>
<a class="btn" href="/override/OverUserOverRide/21801" style="font-size: 15px;"><span class="glyphicon glyphicon-user"></span></a>
</td>
</tr>

  IWebElement t = driver.FindElement(By.XPath("//*table[@id='customerDatatable']"));
            t.FindElement(By.CssSelector("a[href='/override/OverUserOverRide/21801']")).Click();

I have used this code but not working [1]: https://i.stack.imgur.com/eEjzO.png

CodePudding user response:

The problem is in the 1st element t locator, since it's not a valid one:

*"//table[@id='customerDatatable']"

You should use either * (for searching among all tags) or specific tagname (table in your case), so it could be:

- "//*[@id='customerDatatable']"
- "//table[@id='customerDatatable']"
  • Related