Help needed to embed screenshot after each step in BDD Scenario
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Help needed to embed screenshot after each step in BDD Scenario
Iam using IntellijIDEA+cucumber +BDD for testing an android device. I need to include the screenshot also in cucumber report. The screenshot has to be added after each step in scenario. I have tried the Embed method in @After to embed it in report. But I can see only a 'x' button in report. The file seems to be outside the report folder Can anybody pls help
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perhaps it could help ?
Un sourire et ça repart
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It sounds like you're using TestLeft, since you are staying within your Intellij IDE to create tests using cucumber(probs java?)
I'm also not too familiar with cucumber-reports, but they consume the cucumber-json format reports generated by the command that goes something like
@RunWith(Cucumber.class)
@CucumberOptions(
format = {"pretty", "html:target/Destination", "json:report/cucumber.json"},
features = {"src/test/resources/AddOrder.feature"})
public class AddOrderTest {
}
within your test....
I'm not sure if there is an elegent way to view the pictures within your cucumber reports in that case.
I'd point you towards asking the same question within the TestLeft and Cucumber community, since they may have some more insight into doing what you're trying to do!
https://community.hiptest.com/
https://community.smartbear.com/t5/TestLeft/ct-p/TestLeft
Otherwise, if you are considering using TestComplete, with the integration, there are Log.Picture type of built in methods that can post screenshots of each of the step definitions when the test runs publish the mht style logs.
Justin Kim
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Benoit, Justin.
@HarithaSaji please let us know how you managed to solve this.
Sonya Mihaljova
Community and Education Specialist
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi@HarithaSaji ,
Can you give me some more details:
- what version of IntelliJ are you using?
- what version of Cucumber are you using?
- are you running your scenarios against an Android device or a simulator (which version)?
- are you running Cucumber from the IntelliJ integration or using a Cucumber runner (e.g. RunCukesTest)?
- please share your CucumberOptions (if using the runner) or a screenshot of the relevant IntelliJ Run/Debug Configuration
Thanks
Seb
Now available from Leanpub - http://bddbooks.com
The Cucumber for Java Book - Seb Rose, Matt Wynne & Aslak Hellesøy
Now available from the Pragmatic Press - https://pragprog.com/book/srjcuc/the-cucumber-for-java-book
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @HarithaSaji
Try this:
package io.cucumber.skeleton;
import io.cucumber.java.AfterStep;
import io.cucumber.java.Before;
import io.cucumber.java.Scenario;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
public class StepDefinitions {
private TakesScreenshot webDriver;
private Scenario scenario;
@Before
public void before(Scenario scenario) {
this.scenario = scenario;
}
@AfterStep
public void attachScreenshot() {
this.scenario.embed(webDriver.getScreenshotAs(OutputType.BYTES), "image/png", "screenshot");
}
}
If the screenshot doesn't contain what you want, then it's not a problem related to Cucumber, but rather to the tool you are using to take the screenshot (I have assumed WebDriver).
Please also beware that TestComplete (whose forum we're in) and Cucumber are two different products, so please use the Cucumber forum for questions about Cucumber to avoid getting answers about TestComplete 😉
I'm the creator and lead developer of Cucumber Open.
