在selenium-webdriver.jstesting中获取testing标题和状态

我正在用selenium-webdriver.js写摩卡testing,并且只在当前testing失败的情况下尝试截图。

在摩卡,我可以得到当前的testing信息,如标题和状态,如下所示:

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

但是,selenium-webdriver.js使用selenium-webdriver / testing封装了Mocha的接口,原来的这个currentTest不再暴露:

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

我想知道这样的信息是否仍然暴露出来或有任何解决方法。

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

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