【发布时间】:2021-08-06 04:32:25
【问题描述】:
我需要对表的总数进行断言,并在我为图像表中的总数编写 XPath 时执行此操作,它不适用于所有场景。我知道原因,因为表格是动态的,所以有时它只有 1 个图像,有时它有 5 个图像,所以我很难编写适用于所有场景的 x-path。
对于我写的附加图片:enter image description here WebElement totalElement = driver.findElement(By.xpath("//*[@id="image_table"]/tbody/tr[5]/td[4]")); 它运行良好,但是当表格大小发生变化时。失败了。
网页设计如下,供参考,
***<table class="table table-bordered table-striped table-hover display" id="image_table">
<tr>
<td colspan="2" class="text-right">Total</td>
<td class="text-center">1,650</td>
<td class="text-center">19,936</td>
<td class="text-center">21,586</td> (trying to write xpath for this total)
</tr>***
【问题讨论】: