for selenium中的循环不起作用

时间:2015-07-08 04:49:32

标签: java selenium-webdriver

代码:

try {
  //load file into java
  Workbook workbook=Workbook.getWorkbook(sourceForCustomerGroup);

  //load sheet number (0 is sheet 1)
  Sheet sheetForGroups= workbook.getSheet(0);

  Cell c1 = sheetForGroups.getCell(customerColumn, customerRow);
  String customerGroupName = c1.getContents();

  for (int i = 0; i<sheetForGroups.getRows(); i++, customerRow++) {
    driver.findElement(By.id("tab3")).click();
    driver.findElement(By.id("new")).click();
    driver.findElement(By.id("GroupName")).clear();
    driver.findElement(By.id("GroupName")).sendKeys(customerGroupName);
    driver.findElement(By.id("save")).click();

    customerRow = 1;
    customerColumn = 1;

    for (int j = 0; j<sheetForGroups.getRows()-1; j++, customerRow++) {
      Cell c2 = sheetForGroups.getCell(customerColumn, customerRow);
      String clientUserID = c2.getContents();

      driver.findElement(By.id("clientuserid1")).clear();
      driver.findElement(By.id("clientuserid1")).sendKeys(clientUserID);
      driver.findElement(By.id("add")).click();
    }

    //doesn't work here
    driver.findElement(By.id("actions")).click();
    driver.findElement(By.id("save")).click();
  }
}

在第二个for循环之后,代码似乎没有运行命令。我试过手动跟踪它,我认为我没有犯任何逻辑错误(我希望我能够纠正)。怎么了?

0 个答案:

没有答案