When I tried to attach a screenshot captured and saved in selenium project to extent test automation report it gives me an error saying that java.io.IOException: Media was not found at [C:\Users\Suresh\git\BasicFuncTesting\test-output\Screenshot\imageOneBrokenTest.png]
I have given my image path as below.
String imagePath = "C:\\Users\\Suresh\\git\\BasicFuncTesting\\test-output\\Screenshot\\imageOneBrokenTest.png";
I have used 2 methods as below to attach this screenshot but both methods gives me the same error.
logger.addScreenCaptureFromPath(imagePath, "Fail");
logger.fail("Screenshot", MediaEntityBuilder.createScreenCaptureFromPath(imagePath).build());
Here logger is the ExtentTest object.
I was able to successfully generate my extent report with the captured screenshot by setting the variable values as below.
String imagePath = "C:/Users/Suresh/git/BasicFuncTesting/BasicFuncTesting/test-output/Screenshot/1587494732758.png";
try {
logger.fail("Screenshot", MediaEntityBuilder.createScreenCaptureFromPath(imagePath).build());
} catch (Exception e) {
e.printStackTrace();
}