如何为多个客户在 excel 中给出的输入编写 for-loop 以登录到 yahoo。我想要硒数据驱动的测试。
在这里,我需要 B 列而不是 A 列的值,并且我的行需要增加。
那么如何编写for循环
column A .. column B
=====================================
username >>> waxy@yahoo.com
password >>>>123456
username >>>>ABC@yahoo.com
password >>>>123456
我试过下面的代码,
public class yahoo_login {
public static void main(String[] args) throws Exception {
FirefoxDriver fd = new FirefoxDriver();
fd.manage().window().maximize();
fd.get("http:yahoomail.com");
Thread.sleep(1000);
FileInputStream fs = new FileInputStream("E:\\Testing\\Testdata.xls");
Workbook wb = Workbook.getWorkbook(fs);
Sheet s = wb.getSheet(1);
for (int r=0; r<s.getColumns();r++)
{
fd.findElement(By.name("login")).sendKeys(s.getCell(r,1).getContents());
fd.findElement(By.name("passwd")).sendKeys(s.getCell(r,1).getContents());
fd.findElement(By.name(".save")).click();
}
}
}