2016-11-02 41 views
0

我想评估世界文件中的this.BeforeFeature钩子中的标记功能,但我得到错误'TypeError:handler不是函数'。我从错误消息中解释的是,this.BeforeFeature()将函数作为参数,我使用下面的代码。 还有其他的方法可以加速这个问题 - 比如读取功能的名字,但它会完全打败标签的目的,所以我不想采用这种方法。在BeforeFeature钩子中评估黄瓜标签

this.registerHandler('BeforeFeature', {tags: ["@foo,@bar"]} ,function (event, callback) { 
     console.log("before feature") 
     global.browser.driver.manage().window().setSize(500, 800); 
     callback(); 
    }); 

任何帮助表示赞赏。

+0

或只是我猜测,因为场景的继承是功能标签,我应该只是做以下事项'this.Before(“@ foo”,function(scenario){//该钩子将在使用@foo标记的场景之前执行 // ... }); – Galileo123

回答

0

由于场景的继承功能评估对方案中的钩子应该做的求职

继承挂钩工作原理如下─

功能(挂钩) - >方案(钩)/一个方案概述(挂钩 - >例子

this.Before("@foo", function (scenario) { 
    // This hook will be executed before scenarios tagged with @foo // ... 
}); 

希望它helps.Thanks