How to send extent reports in email with screenshots

How to send extent reports in email with screenshots
How to send extent reports in email with screenshots,While working with Extent Reports,we are able to take the screenshots ,able to attach into Extent html Reports,but while sending those reports in email screenshots not displays.

I’ve figured how to display screenshots in Extent Reports,if html file location is changed from one folder to another folder with the simple trick as per Extent Reports site directions.
 

Send Extent Reports in Email

Code Sample

public class SampleTest{
String concatenate = ".";
String screenshot_Name;
// FAIL Screenshots
screenshot_Name = concatenate + getScreenshot(driver, "TestName");
Reporting.testFailLogs("Taking Screenshot for FAIL Step-Reason");
Reporting.screenCapture("TestName", screenshot_Name);
System.out.println("Script Exception Error Message: " + e);

public static String getScreenshot(WebDriver driver, String screenshotName) throws Exception {
File sourceFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
String imgPath = "./" +reports/Screenshots/" + screenshot + "_"+ System.currentTimeMillis() + ".png";
File path = new File("./Reports/" + imgPath);
FileUtils.copyFile(sourceFile, path);
return imgPath;
}
public static Object screenCapture(String logdetails, String imagepath) throws IOException {
// report with snapshot
test.log(Status.INFO, logdetails, MediaEntityBuilder.createScreenCaptureFromPath(imagepath).build());
return test;
}
}

 

ALSO READ  Run Selenium Script using runnable JAR

Please provide your valuable comments on this How to send Extent reports in email with screenshots and give me feedback on this code.Thank you for reading…

Rajesh K

Leave a Reply

Your email address will not be published. Required fields are marked *