0
我想將網絡表的行和列存儲到數組列表中,然後驗證數據。我可以打印行,但我將如何存儲行。如何在arraylist中存儲webtable,然後在selenium webdriver中驗證數據
public void verifyTable() {
String Test = driver.findElement(loggedinas).getText();
boolean isDue = false;
isDue = UtilClass.isElementPresent(driver, TableContent);
if (isDue) {
if (isDue = driver.findElement(TableContent).getText() != null)
;
System.out.println("Action Required = " + isDue);
WebElement table_element = driver.findElement(Table);
List<WebElement> tr_collection = table_element
.findElements(TableRow);
System.out.println("Number Of Due = " + tr_collection.size());
int row_num, col_num;
row_num = 1;
for (WebElement trElement : tr_collection) {
List<WebElement> td_collection = trElement.findElements(By.xpath("td"));
System.out.println("--NUMBER OF COLUMNS = "
+ td_collection.size() + "--");
col_num = 1;
for (WebElement tdElement : td_collection) {
// System.out.println("Pending # "+row_num+", col # "+col_num+
// "text="+tdElement.getText());
System.out.printf(" # " + tdElement.getText(), " ID "
+ tdElement.getText());
col_num++;
}
row_num++;
}
謝謝!
你嘗試使用二維的ArrayList? –
感謝@ApurvChatterjee工作正常,只是好奇,如果表有重複的EmpID,但有差異。 Emp名稱,然後如何使用value.contains(「EmpID」) –
嗨@sumit我相信我們可以有一個單獨的線程相同。 –