email2vimalraj / CucumberExtentReporter

A plugin to generate the cucumber jvm custom html report using ExtentsReport
http://www.vimalselvam.com/cucumber-extent-reporter/
MIT License
58 stars 74 forks source link

Not able to embed screenshots anymore #43

Closed buekera closed 7 years ago

buekera commented 7 years ago

First of all: Thank you very much for providing such a nice plugin! I'm using it for a long time now and never had any problems! :)

Since I updated fo version 2.0.4 cucumber is not able to embed screenshots to the extent reports anymore. I used this code in version 1.1.1 to successfully add screenshots to the report:

byte[] screenshot = ((TakesScreenshot) getDriver()).getScreenshotAs(OutputType.BYTES)
scenario.embed(screenshot, "image/png")

Sadly I'm not able to do this anymore. Strangely cucumber isn't able to take a screenshot at all when using this plugin version. Why did it work flawlessly before and now doesn't even allow me to take screenshots at all? I didn't change anything else...

I already read about the addScreenCaptureFromPath function but I'm not able to use it due to the fact that cucumber isn't able to take screenshots at all anymore.

Kind regards

email2vimalraj commented 7 years ago

From 2.0.4, attaching the screenshot had been changed. Try as follows:

File srcFile = ((TakesScreenshot) getDriver()).getScreenshotAs(OutputType.FILE);
com.cucumber.listener.Reporter.addScreenCaptureFromPath(srcFile.getAbsolutePath());

Please note that the OutputType, I'm using as FILE, not the BYTES anymore.

Cucumber doesn't have any functionality to take the screenshot. Only selenium webdriver has the capability to capture the screenshot.

Hope this solves your problem. I'm closing it, kindly re-open in case you need further help.

buekera commented 7 years ago

I'm now able to add screenshots to the report but when loading the report in my browser these images can't be loaded due to a 404. I checked the path of the image loaded but it's not correct at all. Here the path he is looking for: http://localhost:63342/Users/user/Workspace/Repos/app/test/gui/reports/screenshot8874152909299551043.png Is getAbsolutePath() really the correct way?

Kind regards

email2vimalraj commented 7 years ago

The getAbsolutePath() will never give you this kind of path. Something wrong with your code or implementation. Kindly share some sample for me to reproduce.

Sent from my iPhone

On Apr 11, 2017, at 8:44 PM, chOOnz notifications@github.com wrote:

I'm now able to add screenshots to the report but when loading the report in my browser these images can't be loaded due to a 404. I checked the path of the image loaded but it's not correct at all. Here the path he is looking for: http://localhost:63342/Users/user/Workspace/Repos/app/test/gui/reports/screenshot8874152909299551043.png Is getAbsolutePath() really the correct way?

Kind regards

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

ssundar0 commented 6 years ago

File srcFile = ((TakesScreenshot) getDriver()).getScreenshotAs(OutputType.FILE); com.cucumber.listener.Reporter.addScreenCaptureFromPath(srcFile.getAbsolutePath()

First line will save file only temporary. So when you open that in browser that doesn't exist there anymore. So you should copy that file first locally in any folder you want then you can access that path in second line. You can do that by FileUtils.copy(scrFile, new File(Path of new folder))

msayem commented 6 years ago

Hi, i am not getting the screenshot in Cucumber Extent report. I am copying my images o a folder in project and images are saving but when i open the Extent report and click on the image icon there is no screenshot. Appreciate any help. Thanks image

@email2vimalraj

msayem commented 6 years ago

@email2vimalraj image

elacang commented 6 years ago

Hey @email2vimalraj, I was having the same problem. If you still is looking for a solutions.. Here's my take:

Apparently, you need to put the whole relative path of the image:

File sourcePath = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); File destinationPath = new File(System.getProperty("user.dir") + "/target/test-report/extent-report/screenshots/" + screenshotName + ".png"); copyFile(sourcePath, destinationPath); Reporter.addScreenCaptureFromPath("./screenshots/"+screenshotName+".png");