【发布时间】:2021-09-27 02:03:39
【问题描述】:
<table class="">
<tbody class>
<tr class>
<tr class>
<tr class>
<td>
<span>Series</span>
<td>CAT5</td>
tr 和 td 的数量可以不同,因为有多个表,我需要这样的 xpath 格式:
//table[@class="info-table specifications-table"]/tbody/tr/td/span[contains(text(),'Series')]/....
我试过这样但是tr顺序每次都不一样,唯一不变的是值总是在表的Series行上
//table[@class="info-table specifications-table"]/tbody/tr[8]/td[2]
Table looks like this and the Series can be on different position from top to bottom
【问题讨论】:
-
你尝试了什么?什么不起作用?
-
这是我尝试过但没有工作的,因为 td 不是 span
//table[@class="info-table specifications-table"]/tbody/tr/td/span[contains(text(),'Series')]/following-sibling::td的兄弟 -
添加一个parent selector then? 可能类似于
//table[@class="info-table specifications-table"]/tbody/tr/td/span[contains(text(),'Series')]/parent::td/following-sibling::td -
它正在工作,非常感谢您的帮助