2014-03-25 35 views
1

我正在使用selenium-webdriver.js写摩卡测试,并且只在当前测试失败的情况下尝试截屏。在selenium-webdriver.js测试中获取测试标题和状态

在摩卡,我能得到这样的标题和状态目前的测试信息如下:各地摩卡界面

afterEach(function(){ 
    console.log('afterEach', this.currentTest.title, this.currentTest.state); 
}); 

但硒webdriver.js包装与硒的webdriver /测试,和原来这一点。 currentTest不再暴露:

var test = require('selenium-webdriver/testing'); 
test.afterEach(function(){ 
    //console.log('afterEach', this.currentTest.title, this.currentTest.state); 
}); 

我想知道这样的信息是否仍然暴露在某种程度上或有任何解决方法。

+0

这仍然不适合你吗?我可以在this.currentTest.state上过滤得很好,这可能是在你问这个问题之后实现的,也许吧? – Rubicon

回答

1
this.title - returns suite name 
this.ctx.currentTest.title - returns current test name 
this.ctx.currentTest.state - returns current test state 

如果使用箭头函数进行“描述”,则不起作用。