空手道用户界面独立-故障报告中可以附有屏幕截图吗? [英] Karate UI standalone - can there be screenshots attached to reports on failure?

查看:50
本文介绍了空手道用户界面独立-故障报告中可以附有屏幕截图吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在评估空手道UI,非常喜欢它.我将其用作独立的jar(因为该团队不想支持Java项目,但可以使用JS很好),并且想知道如何附加步骤失败后正确生成的Web应用的屏幕截图?

I am evaluating Karate UI and really like it. I use it as standalone jar (as the team do not want to support Java project but is fine with JS) and am wondering how can I attach screenshots of the web app generated right when a step fails?

我已经看到了这个问题-将屏幕截图附加到json报告,希望它会也可以使用独立版本做一些事情.

I have seen this question - Attaching screenshots to json report and hope it would be possible to doing something with the standalone version as well.

推荐答案

如果您查看挂钩"部分:

If you look at the section on "hooks": https://github.com/intuit/karate#hooks

您应该能够像这样使用afterScenario钩子:

You should be able to use an afterScenario hook like this:

* configure afterScenario = function(){ if (karate.info.errorMessage) driver.screenshot() }

适用于0.9.5.RC4.在最新的官方版本0.9.4中则没有.

Works with with 0.9.5.RC4. With latest official release 0.9.4 it does not.

Edit2-与karate-config.js中的以下行一起全局使用

Edit2 - works globally with the following line in karate-config.js

    karate.configure('afterScenario', read('afterScenarioScreenshot.js'))

afterScenarioScreenshot.js包含上面的JS函数

Where afterScenarioScreenshot.js contains the JS function from above

这篇关于空手道用户界面独立-故障报告中可以附有屏幕截图吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆