[英]how i can send the snapshots of failure testcases in the jenkins email attachment
1 ] 1我正在使用maven项目进行自动化,我想拍摄失败的测试用例的快照并发送附件,快照已捕获并成功保存,但是在Jenkins附件中不起作用,有人可以找出问题吗? 我正在使用Maven项目和Jenkins 捕获图像代码正常工作,并且快照成功保存,但是在Jenkins附件中,快照未在电子邮件中发送
enter code here public static void captureScreenshot(WebDriver driver, String screenshotname) throws Exception {
String timeStamp;
File screenShotName;
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
//The below method will save the screen shot in d drive with name "screenshot.png"
timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime());
//screenShotName = new File("D:\\MyTest\\Screenshots\\"+timeStamp+".png");
screenShotName = new File("D:\\Automation\\EclipseWorkSpace\\WebDriverTest1\\target\\snapshot\\"+timeStamp+".png");
FileUtils.copyFile(scrFile, screenShotName);
String filePath = screenShotName.toString();
//String path = "<img src="\"file://"" alt="\"\"/" />";
String path = "<img src=\"file://" + filePath + "\" alt=\"\"/>";
Reporter.log(path);
}
而不是将屏幕快照存储在“ D:\\ Automation \\ XXX”中,您应该指定一个相对于项目目录的文件夹。 如果Jenkins机器没有“ D:”驱动器,则硬编码路径不起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.