Javascript 保存每个场景后拍摄的屏幕截图时出错
我说world.attach不是函数时出错。 我正在使用自定义世界构造函数,如下所示:Javascript 保存每个场景后拍摄的屏幕截图时出错,javascript,protractor,cucumber,Javascript,Protractor,Cucumber,我说world.attach不是函数时出错。 我正在使用自定义世界构造函数,如下所示: const {setWorldConstructor, attach} = require('cucumber') class CustomWorld{ constructor(){ console.log('initilize stuff here') this.attach = attach; //var EC = protractor.ExpectedConditions;
const {setWorldConstructor, attach} = require('cucumber')
class CustomWorld{
constructor(){
console.log('initilize stuff here')
this.attach = attach;
//var EC = protractor.ExpectedConditions;
}
//Some more code
setWorldConstructor(CustomWorld)
这是我的hooks.js文件
var {After, Status} = require('cucumber');
After(function (testCase) {
var world = this;
if (testCase.result.status === Status.FAILED) {
return browser.takeScreenshot().then(function(screenShot) {
// screenShot is a base-64 encoded PNG
world.attach(screenShot, 'image/png');
});
}
//taking screenshots anyway
else{
return browser.takeScreenshot().then(function(screenShot) {
// screenShot is a base-64 encoded PNG
world.attach(screenShot, 'image/png');
});
}
});
由于我是一个新手,我可能没有做很多正确的。
有谁能帮我保存屏幕截图和生成黄瓜报告吗?
提前感谢类似GitHubGist条目的内容?@Jeroen Heier:这在哪个版本的cucumber上运行?我使用的是4.X版