如何編寫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