【问题标题】:selenium xpath to access various columns links in tableselenium xpath 访问表中的各个列链接
【发布时间】:2011-08-09 07:27:58
【问题描述】:

我正在尝试为表中的各种列链接创建 selenium xpath。每一行都是唯一标识的。在每一行中,我知道一列的名称(产品名称)并根据产品名称尝试在表中查找其他链接以对该产品执行其他操作,例如更改开始日期和结束日期以及删除产品等。

有人可以阐明为表格中的每一列创建 xpath。表名如下:

tooltip nameofprodduct percentage startdate enddate checkbox1 checkbox2 remove

<tr id="225259">

<td><a class="tooltip "><img alt="info" src="media/tooltip.gif" class="tooltip"><div style="display: none;"></a></td>

<td>name(299106)</td>

<td><div class="increse"><div style="display: none;" class="slidermetrics"></div><span onclick="showBoostSlider(225259,0,0,0,0);" class="increse">0%</span></td>

<td nowrap="nowrap" class="start"><span class="nonEdit"><span class="pointer">none</span><a href="#" class="ui-corner-all ui-button-small"><span class="icon-date"></span></a></span><span style="display: none;" class="edit"><input type="text" value="" style="width: 80px; margin-right: 7px;" class="inlineCalendarDisplay"><input type="hidden" value="" class="inlineCalendar"><a href="#" class="close"><span class="icon-cancel"></span></a><a href="#" class="save"><span class="icon-disk"></span></a></span><span class="tablesorterHiddenSortData"></span></td>

<td nowrap="nowrap" class="end"><span class="nonEdit"><span class="pointer">none</span><a href="#" class="ui-corner-all ui-button-small"><span class="icon-date"></span></a></span><span style="display: none;" class="edit"><input type="text" value="" style="width: 80px; margin-right: 7px;" class="inlineCalendarDisplay"><input type="hidden" value="" class="inlineCalendar"><a href="#" class="close"><span class="icon-cancel"></span></a><a href="#" class="save"><span class="icon-disk"></span></a></span><span class="tablesorterHiddenSortData"></span></td>

<td><input type="checkbox" onchange="switchEnabled('PEnabled',this,'225259');" checked="checked"></td>

<td><input type="checkbox" onchange="switchEnabled('SEnabled',this,'225259');" checked="checked"></td>

<td><a onclick="$('#tab3 &gt; table.jsonTable').rGrid('remove',225259); return false;" href="#">remove</a></td>

</tr>

【问题讨论】:

    标签: css xpath selenium


    【解决方案1】:

    您可能正在寻找这个 XPath,它返回具有给定名称的所有表的所有行的所有链接:

     "//table/tr/td[.='name(299106)']/..//a"
    

    要访问特定行的列,您可以使用:

     "//table/tr[id='225259']/td"
    

    【讨论】:

    • 您好,谢谢您的回复,但是我正在寻找 xpath,它允许我访问行中的每一列,从而允许我通过访问唯一行中的列链接文本来执行不同的操作
    • 什么意思?您要选择哪些节点?
    • 对不起,如果我让你感到困惑。所以这是我正在寻找的简单版本。我的表每行包含 8 个不同的列(之前发布的 html 代码)。我想要允许我访问特定行的每一列的 xpath。例如...每行第一列包含“工具提示”链接(访问此链接时显示行摘要),第二列数据是产品名称链接,第三列数据是其他链接。所以我们需要 xpath 来访问显示为链接的每一列数据
    • 我已将 XPath 添加到问题中以选择特定行的所有列。
    猜你喜欢
    • 2021-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多