grasshopper7 / extentreports-cucumber6-adapter

Cucumber-JVM 6 Adapter for Extent Framework
https://ghchirp.online/2098/
MIT License
16 stars 15 forks source link

Screenshots not getting added to extent report even after adding the screenshot.dir property #46

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello @anshooarora and @grasshopper7 , I am using the cucumber6 dependency as mentioned below. and also below is my folder structure and property file. Somehow its not placing screenshots at the location mentioned in property file and also not attaching same to report. please advise if there is something wrong.

tech.grasshopper extentreports-cucumber6-adapter 2.8.4

image

grasshopper7 commented 3 years ago

U have set the base64 image to true. With this setting, no physical image file will be created. A 'base64 img' thumbnail will be added, which when clicked a larger image will be displayed. Set this setting to false or comment it. This should create the physical files. U can refer to the sample implementation for more details - https://github.com/grasshopper7/cuke6-extent-adapter-report

ghost commented 3 years ago

@grasshopper7 still no luck.

image

grasshopper7 commented 3 years ago

Share your repository with minimum code which reproduces the issue, will have a look

ghost commented 3 years ago

@grasshopper7 here is the URI https://github.com/JaydipPatel2009/ExtentSpartReport.git

ghost commented 3 years ago

@grasshopper7 let me know if you find anything that is not compatible. I tried with adapter7 and did not work. Also tried Cucumber version 6.10.2 but it did not work with that either.

grasshopper7 commented 3 years ago

There is no code which is taking screenshot.

TakesScreenshot ts = (TakesScreenshot) driver;
byte[] screenshot = ts.getScreenshotAs(OutputType.BYTES);
scenario.attach(screenshot, "image/png", "");

U should check out the sample implementation referred earlier for more details.

ExtentPdf.pdf reports.zip

If this is production code then it needs to be refactored with how the driver is shared between runners, steps and pages. Also the testng runner just needs to inherit from AbstractTestNGRunner, no need for adding methods.

ghost commented 3 years ago

Thanks for the input @grasshopper7 but where would you put this code? under @test in runner ? or under @afterStep in step definition ? also the extent.property file was correctly written?

grasshopper7 commented 3 years ago

in afterstep and add a condition to only run if scenario fails, if that is the requirement. extent.property is correct.

ghost commented 3 years ago

@grasshopper7 I was able to implement it. Thanks a lot for the guidance and help. Only thing is probably I will have to add little bit of wait time as the thread is taking screenshots very quickly and sometimes if the web page has latency in terms of loading all web elements, it could take improper screenshots.

Appreciate the help.

I will be closing this issue. I will update repo with updated code base.

ghost commented 3 years ago

Hi @grasshopper7 I am reopening the thread as I have one more question. Once I attach the screenshot, the report shows the image fine if opened from local. but for my requirement, I need to send the report to JIRA as an attachment, so once I download from JIRA and open that downloaded report I see the image broken. How can I handle that part?

this is the report downloaded from JIRA once report was sent to JIRA.

Spark.html.zip

ghost commented 3 years ago

Got it. Base64 is the way to do it.