Невозможно сделать снимок экрана с помощью отчета об экстенте 4 (Selenium- Java). Сообщение об ошибке: - НЕУДАЧНАЯ КОНФИГУРАЦИЯ: @AfterMethod tearDown ([TestResult name = expediaTitleCheck status = FAILURE method = Expedia_T C .expediaTitleCheck) () [pri: 0, instance: com.extent.testcases. Expedia_TC@72b6cbcc] output = {null}])
Код выглядит следующим образом: -
public class Expedia_TC {
WebDriver driver;
Expedia exp;
ExtentHtmlReporter htmlReport;
ExtentReports extent;
ExtentTest test;
@BeforeTest
public void startBrowser() {
htmlReport = new ExtentHtmlReporter(System.getProperty("user.dir")+"/Reports/ExpediaReport.html");
htmlReport.config().setEncoding("utf-8");
htmlReport.config().setDocumentTitle("Expedia Automation Report");
htmlReport.config().setReportName("Functional Report");
htmlReport.config().setTimeStampFormat("EEEE,DD-MM-YYYY,hh:mm:ss");
htmlReport.config().setTheme(Theme.DARK);
extent = new ExtentReports();
extent.attachReporter(htmlReport);
extent.setSystemInfo("OS","Windows10");
extent.setSystemInfo("Environment","Production");
extent.setSystemInfo("Tester","Jayashree");
WebDriverManager.firefoxdriver().setup();
System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, "true");
System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE,"/dev/null");
driver = new FirefoxDriver();
exp = new Expedia(driver);
driver.manage().window().maximize();
driver.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS);
}
@Test
public void expediaTitleCheck() {
test = extent.createTest("Title Check Test...");
exp.checkPageTitle();
test.fail("This Test is Failed!");
}
@AfterMethod
public void tearDown(ITestResult result)throws IOException {
if(result.getStatus() == ITestResult.FAILURE) {
String methodName ="<b>"+result.getMethod().getMethodName()+" : "+"FAILED"+"</b>";
String errorMsg = "<b>"+"REASON: "+" "+result.getThrowable().getMessage()+"</b>";
String failureScreenshot = Expedia_TC.captureScreen(driver, methodName);
test.log(Status.FAIL,MarkupHelper.createLabel(methodName,ExtentColor.RED));
test.log(Status.FAIL,errorMsg);
try {
test.addScreenCaptureFromPath(failureScreenshot);
}
catch(Exception e) {
e.printStackTrace();
}
}
}
@AfterTest
public void endReport() {
extent.flush();
driver.quit();
}