Closed Rakshas7 closed 2 months ago
I started working on this, but just realized that the latest master already has this built-in, see below:
private void constructLog(final Log log, final ExtentTest extentTest, final ExceptionInfo ex) {
final Media m = log.getMedia();
if (m != null) {
if (m.getPath() != null) {
extentTest.log(log.getStatus(),
MediaEntityBuilder.createScreenCaptureFromPath(m.getPath()).build());
}
if (((ScreenCapture) m).getBase64() != null) {
extentTest.log(log.getStatus(),
MediaEntityBuilder.createScreenCaptureFromBase64String(((ScreenCapture) m).getBase64()).build());
}
}
if (ex != null) {
if (!extentTest.getModel().hasLog()) {
extentTest.log(log.getStatus(), log.getDetails());
}
final List<Log> logs = extentTest.getModel().getLogs();
final Log lastLog = logs.get(logs.size() - 1);
lastLog.setException(ex);
extentTest.getModel().getExceptions().add(ex);
}
}
Thanks for your efforts. :)
Added log.getDetails() to test log when the condition log.hasMedia() is satisfied. This will add log details to extent report when only the screenshot is appended to a log.