我的表格有 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("-------------------------------------------------- "); }}
添加回答
舉報
0/150
提交
取消