如何编写for-loop登录到雅虎为多个客户在Excel中给出的输入。我想要用于硒数据驱动的测试。硒:for循环(数据驱动测试)
这里我需要来自列B的值而不是列A &我的行需要增加。
那么如何写for循环
column A .. column B
=====================================
username >>> [email protected]
password >>>>123456
username >>>>[email protected]
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();
}
}
}
到目前为止您尝试过哪些?显示一些代码,以便帮助您找到适合您个人需求的解决方案。 – 2014-09-21 10:54:18