extentreports-cucumber7-adapter icon indicating copy to clipboard operation
extentreports-cucumber7-adapter copied to clipboard

Screenshot not attached with ExtentCucumberAdapter.addTestStepScreenCaptureFromPath

Open Soumendu-Khilar opened this issue 2 years ago • 0 comments

I am using Extent Cucumber Adapter 7 and trying to attach screenshot to the step using ExtentCucumberAdapter.addTestStepScreenCaptureFromPath but when I open the reports I see the attachment icon but there is no screenshot visible.

tech.grasshopper extentreports-cucumber7-adapter 1.14.0

======================================== My Extent.properties

extent.reporter.spark.start=true extent.reporter.spark.config=src/test/resources/spark-config.xml extent.reporter.spark.out=./Spark.html screenshot.dir=screenshots/ screenshot.rel.path=./screenshots/

basefolder.name=test-output/reports basefolder.datetimepattern=d-MMM-YY-HH:mm:ss

#test,exception,category,device,author,log,dashboard - default order extent.reporter.spark.vieworder=dashboard,test,category,exception,author,device,log

======================================================== Code for screenshot: TakesScreenshot ts = (TakesScreenshot) WebDriverRunner.getWebDriver(); File screenshot = ts.getScreenshotAs(OutputType.FILE); Optional<File> latestDir = Arrays.stream(Paths.get("/test-output").toFile().listFiles()) .filter(File::isDirectory) .max(Comparator.comparing(File::lastModified)); FileUtils.copyFile(screenshot, new File(latestDir.get() + "/screenshots/attachment00"+counter+".png")); Optional<File> latestFile = Arrays.stream(Paths.get(latestDir.get()+"/screenshots/").toFile().listFiles()) .filter(File::isFile) .max(Comparator.comparing(File::lastModified)); ExtentCucumberAdapter.addTestStepScreenCaptureFromPath(String.valueOf(latestFile.get()))

Since I am taking multiple screenshots I am taking the latest file in the latest folder under test-output.

Soumendu-Khilar avatar Nov 02 '23 12:11 Soumendu-Khilar