Excel 시트에 username
과 password
의 목록이 있습니다.셀렌의 사용자 로그인 인증?
로그인 페이지에 유효한 사용자 자격 증명을 찾으려고합니다. 내가 엑셀에서 6 명 로그인 자격 증명의 총을
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");
}
:
이
내 코드입니다. 그로부터 1 개만 유효한 신임장이며 Excel의 4 위 자리에 있습니다.Excel의 4 위를 달성하면 다음 페이지로 이동합니다.
하지만 다음 2 개의 로그인 자격 증명이 유효한지 확인하고 싶습니다.
어떻게하면됩니까?
을 logined 여부입니다 그리고 나서 다시 시도하십시오. 또는 시트의 행을 foreach로 만들면 드라이버를 초기화하는 새로운 테스트가 만들어 지므로 매번 신선한 상태가됩니다. –
시도 할 때마다 try/catch를 사용하여 로그 아웃 할 수 있습니다. – Andersson