就像在Excel中一样,存在多个行,具有不同的数据集,我想为每个步骤截图,如下所示
driver.get("http://www.google.com/");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot1.png"));
driver.get("http://www.yahoo.com/");
File scrFile1 = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere
FileUtils.copyFile(scrFile1, new File("c:\\tmp\\screenshot2.png"));如何对每个Excel行重复相同的操作。
就好像我硬编码了"Screenshot1,...2等“的值。在结束时,我将只得到2个屏幕截图,而不是每行记录2个屏幕截图。
发布于 2014-01-13 18:28:04
创建FileName字符串代替硬编码的文件路径,可以在截图文件名中传入行号,以便更好地识别截图文件。
File ScreenShot = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.FILE);
StringBuilder FileName = new StringBuilder("C:\\tmp");
FileName.append(ScreenshotName);
FileName.append("_");
FileName.append(rownumber);
FileName.append(".jpeg");
FileUtils.copyFile(ScreenShot, new File(FileName.toString()));https://stackoverflow.com/questions/21087874
复制相似问题