我们能够在本地查看屏幕截图。当我们在詹金斯(Jenkins)中运行作业时,我们无法在范围报告中查看屏幕截图。我们正在使用范围报告v2.41.2。屏幕截图和报告都在同一目录中。请给我们一个解决方案以解决它。
public static String takescreenshot(WebDriver driver, String Screenshotname) throws InterruptedException {
Thread.sleep(3000);
TakesScreenshot ts = (TakesScreenshot) driver;
File src = ts.getScreenshotAs(OutputType.FILE);
String timeStamp = new SimpleDateFormat("MMMdd_yyyy_hh_mmaa").format(Calendar.getInstance().getTime());
String dest = System.getProperty("user.dir")+"\\ATOM_20Report\\"+Screenshotname + "_" + timeStamp + ".png";
try {
FileUtils.copyFile(src, new File(dest));
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("Failed to take screenshot: " + e.getMessage());
}
return dest;
}
public static void passTestwithsc(String Screenshotname, WebDriver driver) {
Assert.assertTrue(true);
String path = null;
try {
path = Helper.takescreenshot(driver, Screenshotname);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
logger.log(LogStatus.PASS, logger.getDescription(),logger.addScreenCapture(path));
}