我在Excel工作表中列出了username
和password
。
我正在尝试查找登录页面的有效用户凭据。
这是我的代码:
Workbook wBook = null;
try {
wBook = Workbook.getWorkbook(new File("C:/Users/jayant.gupta/Desktop/Book1.xls"));
} catch (BiffException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//get sheet
jxl.Sheet s = wBook.getSheet(0);
for(int i=0;i<s.getRows();i++)
{
for(int j=0;j<s.getColumns();j++)
{
Cell cell=s.getCell(j, i);
System.out.println(" "+cell.getContents());
System.out.println("i "+i);
System.out.println("j "+j);
if(j==0){
driver.findElement(By.id("textBoxUserName")).sendKeys(cell.getContents());
}
if(j==1){
driver.findElement(By.id("txtPswd")).sendKeys(cell.getContents());
driver.findElement(By.id("explore")).click();
driver.findElement(By.id("textBoxUserName")).clear();
driver.findElement(By.id("txtPswd")).clear();
}
}
System.out.println("\n");
}
我在excel中总共有6个登录凭据。从中只有1是有效凭证,在excel的第4位。
当我到达excel的第4个位置时,它将我带到下一页。
但我想检查接下来的2个登录凭据是否有效。
我该怎么做?