我有一个表,我想根据名称选择详细信息字段。 例如,我想根据表中的第一个 John(即第 29 行)选择一个详细字段。
用户名coll: usercard-table/div/div/div[2]///div[1]/div/div[2]/div/div[29]/div/div[3]/div/ 详细信息:usercard-table/div/div/div[2]///div[2]/div[2]/div/div[29]/div/div[3]/div/
如何根据名称选择详细信息字段的第 29 行?
我尝试使用类似 //div[2]/div/div[contains(.,'John)[1]]/div/div[3]/div
有简单的html示例代码吗? 您可以尝试野车:
//*[contains(text(),'John')]
(我添加了您的示例中缺少的第二个引用)
如果你有 29 个无法区分的元素,那么:
(//*[contains(text(),'John')])[29]
嗨,感谢您的帮助。这是一个简单的代码示例。我想根据 2e John (div\div\div[3]) 来选择 class="cell-icons-after-text 的 div
<div>
<div>
<div>
</span>
<span name="indicators" class="cell-icons-after-text">
</span>
<span name="value" class="cellText">
<span class="ui-grid-cell-contents-value"><span name="data">John</span></span>
</span>
</span>
</div>
<div>
</span>
<span name="indicators" class="cell-icons-after-text">
</span>
<span name="value" class="cellText">
<span class="ui-grid-cell-contents-value"><span name="data">Will</span></span>
</span>
</span>
</div>
<div>
</span>
<span name="indicators" class="cell-icons-after-text">
</span>
<span name="value" class="cellText">
<span class="ui-grid-cell-contents-value"><span name="data">John</span></span>
</span>
</span>
</div>
</div>
<div>
<div>
</span>
<span name="indicators" class="cell-icons-after-text">
</span>
<span name="value" class="cellText">
<span class="ui-grid-cell-contents-value"><span name="data">John</span></span>
</span>
</span>
</div>
<div>
</span>
<span name="indicators" class="cell-icons-after-text">
</span>
<span name="value" class="cellText">
<span class="ui-grid-cell-contents-value"><span name="data">Will</span></span>
</span>
</span>
</div>
<div>
</span>
<span name="indicators" class="cell-icons-after-text">
</span>
<span name="value" class="cellText">
<span class="ui-grid-cell-contents-value"></span>
</span>
</span>
<div>
</span>
<span name="indicators" class="cell-icons-after-text">
</span>
<span name="value" class="cellText">
<span class="ui-grid-cell-contents-value"></span>
</span>
</span>
<div>
</span>
<span name="indicators" class="cell-icons-after-text">
</span>
<span name="value" class="cellText">
<span class="ui-grid-cell-contents-value"></span>
</span>
</span>
</div>
</div>
</div>