Not able to open screenshot when using extended reports

Hi,

Currently I am using extended reports with cucumber and I am also taking screenshot with below command
File scrFile = ((TakesScreenshot) MobileTypeHelper.driver).getScreenshotAs(OutputType.FILE);

But when report is generated I am not able to open the screenshot, the images displayed is broken

I have attached the screenshot for ur reference.

Please suggest some alternate method to append screenshot in cucumber report

If you store the image on the disk, are you able to open it?

I have created a folder in eclipse like this:

public static void takeScreenshot() throws IOException {

	destDir = "screenshots";
	File scrFile = ((TakesScreenshot) MobileTypeHelper.driver).getScreenshotAs(OutputType.FILE);

	dateFormat = new SimpleDateFormat("dd-MMM-yyyy__hh_mm_ssaa");
	new File(destDir).mkdir();
	String destFile = dateFormat.format(new Date()) + ".jpg";

	try {
		FileUtils.copyFile(scrFile, new File(destDir + "/" + destFile));
	} catch (IOException e) {
		e.printStackTrace();
	}
}

and from cucumber runner class I am using this command

Reporter.addScreenCaptureFromPath(“screenshots”);

It is taking the screenshot and storing it in folder but it is not opening in cucumber extended report

Hi

If you look at a screenshot placed in the “screenshots” dir with another tool, e.g - microsoft paint - will it open it?

do you have an issue only with the cucumber reporter?

I am able to open screenshot in MS paint. and yes I have only issue in cucumber reporter.

can you suggest some alternate method to embed screenshot in reports?

from the sound of it, it sounds like an issue with the cucumber reports and not really related to appium studio

I guess you’ll need to find out what’s the format which can be displayed with cucumber reports

From a quick search, it looks like you are using a wrong type (OutputType.FILE)

you can try the following code

            if (driver instanceof TakesScreenshot) {
                TakesScreenshot camera = (TakesScreenshot) driver;
                byte[] screenshot = camera.getScreenshotAs(BYTES);
                scenario.embed(screenshot, "image/png");
            }

Sorry for late reply,
by using above code it is giving me java.lang.NullPointerException error