extentreports-cucumber6-adapter
extentreports-cucumber6-adapter copied to clipboard
screen shot - extent report issues
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