anshooarora / extentreports-java

Community version of Extent API for Java has moved to https://github.com/extent-framework/
http://extentreports.com
Other
528 stars 318 forks source link

Unable to View Screenshot on Extent Report 3 (JAVA) on Firefox #871

Open maliwalm opened 7 years ago

maliwalm commented 7 years ago

Summary

Unable to View Screenshot on Extent Report 3 (JAVA) on Firefox

Expected Behavior

User should be able to View Screenshot on Extent report irrespective of Browser.

Current Behavior

1 User is able to view the screenshot for other can't Note - both the users are using the same code set

Sample

calling in beforeSuite of TestNG extent = ExtentManager.getInstance();

public class ExtentManager {

private static ExtentReports extent;

public static ExtentReports getInstance() {
    Config.initConstants();
    if (extent == null)
        createInstance(Config.ExtentReportsPath);
    return extent;
}

public static ExtentReports createInstance(String fileName) {
    Config.initConstants();
    ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(fileName);
    htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
    htmlReporter.config().setChartVisibilityOnOpen(true);
    htmlReporter.config().setTheme(Theme.DARK);
    htmlReporter.config().setDocumentTitle(Config.ReportTitle);
    htmlReporter.config().setEncoding("utf-8");
    htmlReporter.config().setReportName(Config.ReportName);
    extent = new ExtentReports();
    extent.attachReporter(htmlReporter);

    return extent;
}

}

Environment Details

Browser version mentioned in comments

Screenshots

report file attached

anshooarora commented 7 years ago

Are you saving the snapshots relative to the report? And, when moving the report, are you also moving all the artifacts(images, files etc) along?

maliwalm commented 7 years ago

I am saving the Report in folder //Reports & Screenshots on //Reports//Screenshot

Below is the AfterMethod of TestNG

@AfterMethod protected void AfterMethod(ITestResult result) throws IOException {
log.info(" : TestBase - AfterMethod called"); if (result.getStatus() == ITestResult.FAILURE) {
String screenShotPath = Util.captureScreenshot(eventDriver, "Failure"); test.get().fail(result.getThrowable()); test.get().fail(MarkupHelper.createLabel(result.getName() + "Test case FAILED" , ExtentColor.RED)); test.get().fail("Snapshot below: " + test.get().addScreenCaptureFromPath(screenShotPath)); } else if (result.getStatus() == ITestResult.SKIP) test.get().skip(result.getThrowable()); else test.get().pass("Test passed");

    if(eventDriver!=null) 
        eventDriver.quit();
}

public static String captureScreenshot(WebDriver driver,String screenshotName) {
log.info(" : CaptureScreeshot Method Called"); try {
TakesScreenshot ts=(TakesScreenshot)driver; File source=ts.getScreenshotAs(OutputType.FILE); String dest = System.getProperty(("user.dir"))+ "\Reports\ScreenShots\"+screenshotName+ "_" + Util.generateUniqueName() + ".png"; File destination = new File(dest); FileUtils.copyFile(source, destination); return dest; } catch (Exception ex) {
log.error(ex.getMessage()); ex.printStackTrace(); return ex.getMessage(); }
}

maliwalm commented 7 years ago

This is a Browser specific issue which is working fine on Chrome but failing on Firefox

maliwalm commented 7 years ago

I am using the latest version of both the browsers - Chrome - Version 58.0.3029.110 (64-bit) Firefox - 53.0.2 (64-bit)