我正在研究一个函数,该函数在表中采用两个值,然后验证包含两个值的行以验证该行中是否存在第三个值。
下面的代码查找两个值所在的行。但是,如果rowNo和rowNo2相等,它将不会脱离for循环。我尝试使用.equals(),但这给了我一个错误。有提示吗?
try {
// Get the row number of passed row Data
WebElement table = oWebDriver.getWebElement(tableObject);
List<WebElement> rows = table.findElements(By.tagName("tr"));
List<WebElement> cols = table.findElements(By.tagName("td"));
int colSize = (cols.size()) / (rows.size());
int rowNo = 0;
int rowNo2 = 0;
int colNo = 0;
for (int i = 0; i < cols.size(); i++) {
WebElement cellData = cols.get(i);
if (cellData.getText().contains(rowData)||cellData.getText().contains(rowData.toUpperCase())) {
int l = i / colSize;
rowNo = l + 1;
for (int k = 0; k < cols.size(); k++) {
WebElement cellData2 = cols.get(k);
if (cellData2.getText().contains(rowData2)||cellData2.getText().contains(rowData2.toUpperCase())) {
int n = k / colSize;
rowNo2 = n + 1;
}
System.out.println("row No2 = " + rowNo2);
System.out.println("row No1 = " + rowNo);
if (rowNo == rowNo2) {
break;
}
}
}
}