【问题标题】:Unable to generate screenshot in Cucumber Extent Report无法在 Cucumber 范围报告中生成屏幕截图
【发布时间】:2019-11-16 14:28:54
【问题描述】:

我无法在黄瓜的范围报告中看到屏幕截图。

我已经调试并观察到代码被执行了,但是截图没有保存在extent report或者cucumber html report的文件中。

截图代码

public void screenshot(Scenario scenario) { 

if(scenario.isFailed()) { byte[] screenshot=SeleniumUtils.captureScreenshot();场景.公共无效截图(场景场景){嵌入(截图,“image1/png”); }

跑步者类

@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/java/features", tags = "@login_internal_user", glue 
 = {
    "stepDefinitions"
}, plugin = {
    "pretty",
    "rerun:src/test/java/features/rerun.txt",

 "com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:",
    "html:reports"
}
)

公共类 loginRunner {

@AfterClass
public static void teardown() {
    SeleniumUtils.quitDriver();
}
}

Extent.properties 文件

# indicate which reporters to use

 extent.reporter.logger.start=true
 # point to any configuration used
 extent.reporter.logger.config=src/main/resources/extent-config.xml

  # specify output path
  extent.reporter.logger.out=reports/importsTeam-reports
  screenshot.dir=reports/importsTeam-reports/screenshots/

Maven 属性 Extent Cucumber 适配器版本 - 1.0.7 黄瓜罐 - 4.2.0

【问题讨论】:

    标签: selenium-webdriver cucumber extentreports


    【解决方案1】:

    您应该使用 html 报告器。你的属性文件应该包括,

    extent.reporter.html.start = true
    extent.reporter.html.config = <html config xml>
    extent.reporter.html.out = <output path>
    

    【讨论】:

    • 我试过了,但我仍然看不到屏幕截图。我也尝试过使用原生黄瓜 html 记者,但也没有看到。
    • 你收到 html 范围报告了吗?
    • 是的,但是我观察到适配器无法从 extent.properties 文件中选择配置。我尝试了以下调试方法: 1. 注释 extent.properties 中的值并检查是否生成报告.根据 extent-report 配置 xml 成功生成报告。 2. 我在一个静态块中添加了extent.properties 作为system.setproperty。同样,我观察到报告是在没有选择配置的情况下生成的。
    • 测试资源文件夹中是否有属性文件。 ?默认情况下,屏幕截图在 test-output 文件夹下被捕获。
    • 是的,属性文件存在于测试资源文件夹下,但未捕获屏幕截图。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-28
    • 2021-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多