提问人:Елена 提问时间:10/12/2023 最后编辑:ShawnЕлена 更新时间:10/12/2023 访问量:28
XPath 无法识别 datagrit 中的不同表
XPath doesn't recognize different tables in datagrit
问:
我正在尝试自动测试以使用多个表测试数据网格。当我展开第一个表时,它显示了行,每个行也可以展开,并出现与此行对应的层次结构中的下一个表。
我的目标是从两个表中分别获取列名。当我使用XPATH程序成功找到两个表头时,但是当我尝试获取具有单个表列名的元素时,例如:或者它从两个表中获取所有列名,我不明白为什么。//thead[@class = 'k-table-thead']
(//thead[@class = 'k-table-thead'][0] or [1])
//thead[@class = 'k-table-thead'][1]/th
//thead[@class = 'k-table-thead'][2]/th
答:
0赞
Siebe Jongebloed
10/12/2023
#1
假设以下 html
<body>
<table>
<thead class="k-table-thead">
<th>First th of the first thead</th>
<th>Second th of the first thead</th>
</thead>
<tbody>
<tr>
<td>Some text</td>
<td>Some text</td>
</tr>
</tbody>
</table>
<table>
<thead class="k-table-thead">
<th>First th of the first thead</th>
<th>Second th of the first thead</th>
</thead>
<tbody>
<tr>
<td>Some text</td>
<td>Some text</td>
</tr>
</tbody>
</table>
</body>
//thead[@class = 'k-table-thead'][1]/th
通常会选择th
thead
table
//thead[@class = 'k-table-thead'][2]/th
通常会选择 SELECT ALL 'S OF THE SECOND IN A TABLE,可能永远不会有任何内容,因为大多数表只有一个 thead。th
thead
你有一些选择
(//thead[@class = 'k-table-thead'])[2]/th
将从所有 s 中选择第二个,并且从所有 s 中选择第二个thead
thead
th
或
//table[thead[@class = 'k-table-thead']][2]/thead/th
将选择第二个具有适当thead
table
thead
下一个:带旋转代理的硒丝增加了刮削时间
评论