目前我以这种方式截取我的测试失败的截图:
@AfterMethod(alwaysRun=true)
public void catchExceptions(ITestResult result){
Calendar calendar = Calendar.getInstance();
SimpleDateFormat formater = new SimpleDateFormat("dd_MM_yyyy_hh_mm_ss");
String methodName = result.getName();
if(!result.isSuccess()){
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
try {
FileUtils.copyFile(scrFile, new File((String) PathConverter.convert("failure_screenshots/"+methodName+"_"+formater.format(calendar.getTime())+".png")));
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我可以将自己的屏幕截图包含在TestNG报告链接或图片中吗?如果有,怎么样?
我在网上找到的只是FEST框架.但由于我已经截取屏幕截图,我不想使用另一个框架.