grasshopper7 / extentreports-cucumber7-adapter

Cucumber-JVM 7 Adapter for Extent Framework
https://ghchirp.online/3196/
MIT License
17 stars 8 forks source link

Screenshot not attached with ExtentCucumberAdapter.addTestStepScreenCaptureFromPath #35

Open Soumendu-Khilar opened 11 months ago

Soumendu-Khilar commented 11 months ago

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 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 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.