【问题标题】:How we can access hyper link from table td in selenium c#我们如何在 selenium c# 中从表 td 访问超链接
【发布时间】:2021-11-24 22:40:23
【问题描述】:
<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();

我已使用此代码但无法正常工作。 Link

【问题讨论】:

    标签: c# selenium selenium-webdriver hyperlink webdriver


    【解决方案1】:

    问题在于第一个元素 t 定位器,因为它不是一个有效的定位器。

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

    您应该使用 *(用于在所有标签中搜索)或特定的 TagName(在您的情况下为表格),所以它可能是:

    //*[@id='customerDatatable']
    

    //table[@id='customerDatatable']
    

    【讨论】:

    • Message=no such element: Unable to locate element: {"method":"css selector","selector":"a[href='/override/OverUserOverRide/21801']"} 请检查下一行问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-11
    • 2014-07-23
    • 2014-03-02
    • 1970-01-01
    • 2018-05-07
    • 1970-01-01
    相关资源
    最近更新 更多