I am using Extent Report for my selenium Test.
Capture screenshot:
public String captureScreen() throws IOException {
TakesScreenshot screen = (TakesScreenshot) driver;
File src = screen.getScreenshotAs(OutputType.FILE);
String dest = "./reports/" + System.currentTimeMillis() + ".png";
File target = new File(dest);
FileUtils.copyFile(src, target);
return target.getAbsolutePath();
}
public ExtentTest startTestCase(String testName) {
test = extent.createTest(testName);
return test;
}
public void endTestcase() {
extent.setAnalysisStrategy(AnalysisStrategy.CLASS);
}
public void endResult() {
extent.flush();
}
To attach screenshot I am using below code:
test.pass("Navigated to Payment Step 1 Page",MediaEntityBuilder.createScreenCaptureFromPath(captureScreen()).build());
But the report looks good in local.. But I wanted to send the extent report in email.. The images are not displayed.
How to resolve this?
You will have to store and link images from a shared or http location in order for them to be viewable. Or, send a zip file with all images attached. Not sure how good the report will be viewed over email as there is a specific template for email.