我有一个带有页眉(1 行)和页脚(1 行)的表格。我得到的表大小和期望值为 50,但它返回 52,因为它同时计算页眉和页脚行。有没有一种方法可以在我的代码中排除页眉和页脚行并获得实际的预期值。这是我获取表格大小的代码
public int getTableSize() throws InterruptedException{
List<WebElement> columnElements = driver.findElements(By.cssSelector("table[class='table table-bordered table-hover ng-isolate-scope']>tbody>tr"));
return columnElements.size();
}
最佳答案
您可以在选择器中使用 :not 来否定第一个子级和最后一个子级
table[class='table table-bordered table-hover ng-isolate-scope']>tbody>tr:not(:first-child):not(:last-child)
关于java - 获取表大小时如何排除表的第一行和最后一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31971478/