How to capture a screenshot after each step in tes

2020-02-01 06:13发布

What would be the best way to capture screenshots after each step when running integration tests?

Tests are written in Java using Selenium(3.0.1) and Cucumber(1.2.4).

Code for taking a screenshot after a test is below, but I need a screenshot after each method annotated with @Given, @When, @Then.

@After
public void after(Scenario scenario){
    final byte[] screenshot = driver.getScreenshotAs(OutputType.BYTES);
    scenario.embed(screenshot, "image/png");
}

Thank you for any hints.

8条回答
The star\"
2楼-- · 2020-02-01 07:07

I don't think it would be possible until following merge request is accepted and merged. if you are really interested you can merge it locally and have your own custom Jar.

https://github.com/cucumber/cucumber-jvm/pull/838

查看更多
你好瞎i
3楼-- · 2020-02-01 07:08
登录 后发表回答