Skip to content

screen shot - extent report issues #44

@p00rni

Description

@p00rni

HI

I hope it is ok to ask for help here regarding screenshots attachment to extent reports.
I have the following screen shot code in my framework to attach screenshots :

this method in a base page or a geneneric methods class 👍
public static byte[] getByteScreenShot() throws IOException {

	File src = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
	byte[] fileContent = FileUtils.readFileToByteArray(src);
	return fileContent;

}

and i call this method in every cucumber steps class with below code to screenshot and attach for failed tests
@after
public void addScreenshot(Scenario scenario) throws IOException {
if (scenario.isFailed())
{
scenario.attach(BasePage.getByteScreenShot() , "image/png", ".png");}

this is taking screenshots fine but i notice that it is taking screenshot for every step instead of failed ones and are stored in screenshots folder as directed from extent.properties file.

but while attaching screenshots it is attaching irrelevant or wrong screenshots to the report.

is there a way to just take screenshot of only when test fails and not everystep ?

thanks

Poornima

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions