使用CucumberJS 执行测试后,是否有选项或配置可以捕获有关错误的屏幕截图?
答案 0 :(得分:1)
您可以通过黄瓜After
钩进行截图,如下所示:
// supports/take-screenshot.js
var { After, Status } = require("cucumber");
After(function(testCase) {
var me = this;
if (testCase.result.status === Status.FAILED) {
return browser.takeScreenshot().then(function(screenshot) {
return me.attach(screenshot, "image/png");
});
}
});
然后将上述挂钩文件包含在量角器conf.js中的cucumberOpts.requires
中,如下所示:
// cucumberOpts in protractor conf.js
cucumberOpts: {
require: [
"supports/cucumber-screenshot.js",
"steps/**/*step.js"
]
}