我需要将从Webtables获取的值与使用Selenium在Excel中显示的值进行比较。我厌倦了将Excel值添加到列表中并与从webtable中获取但不起作用的列表值进行比较< / p>
@Test(dataProvider = "DP1")
public void csb(String Type, String BranchName, String Address, String
PhoneandEmail) throws InterruptedException {
String title = driver.getTitle();
Thread.sleep(5000);
Select options = new Select(
driver.findElement(By.xpath(".//*[@id='node-129']/div/div/div/div/form/div[1]/select")));
options.selectByValue("Tamil_Nadu");
int size = options.getOptions().size();
System.out.println(size);
List<WebElement> row = driver
.findElements(By.xpath(".//*[@id='node-129']/div/div/div/div/form/div[2]/div/table/tbody/tr"));
List<WebElement> column = driver
.findElements(By.xpath(".//*[@id='node-129']/div/div/div/div/form/div[2]/div/table/thead/tr/th"));
rowCount = row.size();
columnCount = 4;
ArrayList<String> Data = new ArrayList<String>();
Data.add(Type);
Data.add(BranchName);
Data.add(Address);
Data.add(PhoneandEmail);
System.out.println(Data);
System.out.println("Row :" + rowCount + " Clounm :" + columnCount);
tableVal = new String[rowCount][columnCount];
for (int i = 1; i <= rowCount; i++) {
for (int j = 1; j <= columnCount; j++) {
// get table data values
tableVal[i - 1][j - 1] = driver.findElement(By.xpath(".//table/tbody/tr[" + i + "]/td[" + j + "]"))
.getText();
String Values = driver.findElement(By.xpath(".//table/tbody/tr[" + i + "]/td[" + j + "]")).getText();
Datauser.add(Values);
}
}
System.out.println(titel);
System.out.println("Values are" + Datauser);
Assert.assertEquals(Data, Datauser);
}
@DataProvider(name = "DP1")
public Object[][] createData1() throws Exception {
Object[][] retObjArr = getTableArray("data.xls", "Sheet1", "dp1");
return (retObjArr);
}
@AfterTest
public void close() {
driver.close();
}
}