场景失败时的黄瓜快照 - 不起作用

时间:2017-10-26 03:00:23

标签: java selenium junit cucumber

当场景失败时,我目前对快照有以下实现 -

@After("@destroy")
public void tearDown(Scenario scenario) throws Throwable {
    try {
        if (scenario.isFailed()) {

            final byte[] screenshot = ((TakesScreenshot) driverC).getScreenshotAs(OutputType.BYTES);
            scenario.embed(screenshot, "image/png");

            /*
             * final File screenshot = ((TakesScreenshot)
             * driverC).getScreenshotAs(OutputType.FILE);
             * FileUtils.copyFileToDirectory(screenshot, new
             * File("/home/ninad/eclipse-workspace/Reports/html"));
             */

        }
    } catch (WebDriverException somePlatformsDontSupportScreenshots) {
        System.err.println(somePlatformsDontSupportScreenshots.getMessage());
    } finally {
        driverC.close();
    }

}

这些是我的情景 -

Scenario: Filter Airline with Dropdowns
Given element with id "at-offloadsreceived" is displayed 
When I select option "string:OMA" from dropdown "at-usrAirlineDropDown" 
And I click element with id "at-filterBtn" 
Then element with id "at-hdr-tailsign" is displayed
And element with id "at-link-tailsign-20" is displayed 



@destroy 
Scenario: Navigate to Home and Shutdown 
Given I am on the "/#/ted/home" page 
Then element with id "landing_header" is displayed 

我看到了不同的问题:

  1. 不会拍摄任何快照,然后进行嵌入。

  2. 如果在具有@destroy标记的方案中发生错误,则将拍摄快照,但在上一个方案中,如果出现错误,则不会拍摄快照。

  3. 嵌入往往不起作用,只保存在另一个位置(注释掉的代码)有效。
  4. 有错误的多个方案,所有这些方案都没有快照。只会生成一个快照。
  5. 任何帮助将不胜感激。仅供参考 - 我是新手,所以一步一步的指示是最好的! :)

0 个答案:

没有答案