我的表格有 tagName“td”和“mat-cell”。我已经实现了如下示例的源代码,它只获取具有 tagName 的单元格的值为“td”。
如何获取包含 tagName 为“td”或“mat-cell”的数据?
WebElement 表 = driver.findElement(taskListTablexpath);
List<WebElement> rows = table.findElements(By.tagName("tr"));
int row_count = rows.size();
System.out.println("Total Row: " + row_count);
for (int row = 0; row < row_count; row = row + 2) {
**List<WebElement> columns = rows.get(row).findElements(By.tagName("td"));**
int columns_count = columns.size();
System.out.println("Number of cells In Row " + row + " are " + columns_count);
for (int column = 0; column < columns_count; column++) {
String celtext = columns.get(column).getText();
if (celtext == null)
continue;
System.out
.println("Cell Value of row number " + row + " and column number " + column + " Is " + celtext);
}
System.out.println("-------------------------------------------------- ");
}
}
jeck猫
MMTTMM
相关分类