在Hooks.java中加入如下代码即可:
@After
public void afterScenario(Scenario scenario) {
if (scenario.isFailed()) {
// Take a screenshot...
final byte[] screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
// ... and embed it in the report.
scenario.embed(screenshot, "image/png");
}
}
截图如下: