【问题标题】:How to take screenshots in a module in geb如何在geb的模块中截屏
【发布时间】:2016-12-19 17:42:08
【问题描述】:

您好,我们在 Spock 框架上运行 Geb 测试。我正在尝试使用报告“屏幕截图”在模块中截屏。它不像在 Spec 上那样识别报告功能。我应该如何在模块中截屏。

这是一个模块中的示例代码。

try{
    $(By.xpath("//button[@ng-click=\"ok()\"]")).click()
   }
catch (Throwable t){
                                                                  failures.add("\n Could not click on the Ok button after the Ticket created successfully message appeared")

report "Failure"
}

【问题讨论】:

    标签: spock geb


    【解决方案1】:

    report() 方法可用于 Browser 类,并且该类的实例可用作模块内的 browser 属性,因此您可以使用以下方法从模块内调用它:

    browser.report("Failure")
    

    【讨论】:

    • @VinuMahalingam 你能把这个答案标记为正确的吗?
    【解决方案2】:

    使用父类GebReportingSpec(而不是GebSpec)创建所有测试的报告。

    如果您只想要失败测试的屏幕截图,请在您的 GebConfig.groovy 中使用配置值 reportOnTestFailureOnly=true

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-31
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多