Automatically take a screenshot on failure of a Cucumber scenario

If you are using Cucumber to automate testing your web application, it can be useful to include a screenshot in Cucumber’s report whenever a scenario fails.

Cucumber itself doesn’t provide functionality for taking screenshots, but it does make it possible to embed them in the report. If you are using Cucumber together with a Selenium WebDriver, which can capture screens, it’s easy as pie. All you have to do is paste the following lines of Java code into your Cucumber steps definition:

2 Replies to “Automatically take a screenshot on failure of a Cucumber scenario”

Leave a Reply

Your email address will not be published. Required fields are marked *

3 + five =