保存每个场景后拍摄的屏幕截图时出错

时间:2018-09-03 14:23:23

标签: 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;
  }
 //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');
      });
  }
});

由于我是对此的新手,所以我可能做得不正确。 谁能帮我保存黄瓜的屏幕截图并生成报告吗? 在此先感谢

0 个答案:

没有答案
相关问题