Karate UI standalone - can there be screenshots attached to reports on failure?

走远了吗. 提交于 2021-02-08 07:19:53

问题


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?

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.


回答1:


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

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

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

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

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

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

Where afterScenarioScreenshot.js contains the JS function from above



来源:https://stackoverflow.com/questions/59035421/karate-ui-standalone-can-there-be-screenshots-attached-to-reports-on-failure

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!