I have two @after tags, @close-browser and @screenshot.So, right now when I use both tags for feature file it is first executing @close-browser and It fails in executing after method for @screenshot. Is there a way that I can tell cucumber to run @screenshot after method first?
The screenshot should be taken in one of the @After
annotated methods. Like this:
@After
public void finish(Scenario scenario) {
try {
byte[] screenshot =
helper.getWebDriver().getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
} catch (WebDriverException somePlatformsDontSupportScreenshots) {
System.err.println(somePlatformsDontSupportScreenshots.getMessage());
}
finally {
helper.getWebDriver().close();
}
}