问题
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