0
보고서를 테스트하지 못하는 경우 스크린 샷을 추가하려고합니다. 나는이 튜토리얼에 따라 실행하고있어 : http://toolsqa.com/selenium-webdriver/testng-reporters-asserts/보고서를 테스트 할 때 '보고서 출력'이 비어 있습니다.
내 기능
public static void onTestFailure(ITestContext tc, ITestResult result, WebDriver driver) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat formater = new SimpleDateFormat("dd_MM_yyyy_hh_mm_ss");
String methodName = result.getName();
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
try {
String reportDirectory = new File(System.getProperty("user.dir")).getAbsolutePath() + "\\test-output\\" +tc.getSuite().getXmlSuite().getName();
System.out.printf(reportDirectory);
File destFile = new File((String) reportDirectory+"\\failure_screenshots\\"+methodName+"_"+formater.format(calendar.getTime())+".png");
FileUtils.copyFile(scrFile, destFile);
Reporter.log("<a href='"+ destFile.getAbsolutePath() + "'> <img src='"+ destFile.getAbsolutePath() + "' height='100' width='100'/> </a>");
} catch (IOException e) {
e.printStackTrace();
}
}
문제는 ttht 스크린 샷 적절한 장소에 나타납니다,하지만 Reporter.log에서 링크는 결코에 '리포터 출력'보기를 얻을 수 없습니다.
아무도 내가 제대로 작동하도록하려면 어떻게해야합니까?
그것은 받는다는
당신은이 목적을 위해 수신기를 사용할 필요가
이 메소드는 다음과 같이 호출됩니다. @ Test 주석 메소드 이후 또는 @ afterTest 주석 메소드에서? –
@AfterMethod 주석이 달린 메소드에 있는데, (result.FAILURE == result.getStatus()) 그 다음 스크린 샷과 로깅 링크를 호출합니다. – Pawel
Reporter.logs는 @_Test 주석이 달린 메소드 내에서만 작동합니다. 사용자 지정 로그를 보고서에 추가하려면 수신기를 구현해야합니다. 아래의 코드 스 니펫을 확인하십시오. –