Attaching Screenshot to the cucumber report is not working when run in console or jenkins

Hi All,

I am trying to attach screenshot to the cucumber report after the failure of a test run. Using test listener with @After I am able to take and embed screenshot when run with katalon studio. However if I run the same in console(Command Prompt) or through jenkins it is not working.

@After tag does not work in console.

I am using Import cucumber.api.java.After

Can anyone help @devalex88

Thanks in advance.

@kazurayam can you help me on the above issue i am also facing the same issue. The screenshot that is taken with the help of ashot is working fine when i run it in the Katalon IDE and it even gets embed to the report. But where as when i run in the console or in Jenkins it doesn’t invoke the @After method. I have been searching for a solution from a very long time.
Please help. Thanks in advance

Hi guys,
I am experiencing the same issue - works locally, but not if ran in console. Is there any solution/workaround yet?

I am having the following listener:

import java.nio.file.Files
import cucumber.api.java.After
import cucumber.api.Scenario
.
.
.
@After
public void embedScreenshot(Scenario scenario) {
if(scenario.isFailed()) {
String filePath = WebUI.takeScreenshot()
File file = new File(filePath)
scenario.embed(Files.readAllBytes(file.toPath()), “image/png”)
}
}