当您 运行 数据驱动时的代码
code for when you run a Data Driven
在给定字段中执行数据驱动时,代码为其执行,而不是运行下一步的代码。
//poi
WebElement searchbox = driver.findElement(By.name("simcard"));
try
{
FileInputStream file = new FileInputStream(new File("C:\paulo.xls"));
HSSFWorkbook workbook = new HSSFWorkbook(file);
HSSFSheet sheet = workbook.getSheetAt(0);
for (int i=1; i <= sheet.getLastRowNum(); i++)
{
String simcard = sheet.getRow(i).getCell(0).getStringCellValue();
searchbox.sendKeys(simcard);
searchbox.submit();
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.MILLISECONDS);
}
workbook.close();
file.close();
}
catch (FileNotFoundException fnfe)
{
fnfe.printStackTrace();
}
catch (IOException ioe)
{
ioe.printStackTrace();
必须执行的后续步骤
driver.findElement(By.xpath("/html/body/table/tbody/tr[4]/td/div/form/table/tbody/tr[2]/td/center/table/tbody/tr[19]/td/a[1]/img")).click();
有人经历过吗?
已解决,我的代码中存在一些错误,因为已修复
在给定字段中执行数据驱动时,代码为其执行,而不是运行下一步的代码。
//poi
WebElement searchbox = driver.findElement(By.name("simcard"));
try
{
FileInputStream file = new FileInputStream(new File("C:\paulo.xls"));
HSSFWorkbook workbook = new HSSFWorkbook(file);
HSSFSheet sheet = workbook.getSheetAt(0);
for (int i=1; i <= sheet.getLastRowNum(); i++)
{
String simcard = sheet.getRow(i).getCell(0).getStringCellValue();
searchbox.sendKeys(simcard);
searchbox.submit();
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.MILLISECONDS);
}
workbook.close();
file.close();
}
catch (FileNotFoundException fnfe)
{
fnfe.printStackTrace();
}
catch (IOException ioe)
{
ioe.printStackTrace();
必须执行的后续步骤
driver.findElement(By.xpath("/html/body/table/tbody/tr[4]/td/div/form/table/tbody/tr[2]/td/center/table/tbody/tr[19]/td/a[1]/img")).click();
有人经历过吗?
已解决,我的代码中存在一些错误,因为已修复