gpt4 book ai didi

node.js - 在 selenium-webdriver.js 测试中获取测试标题和状态

转载 作者:太空宇宙 更新时间:2023-11-03 22:54:53 28 4
gpt4 key购买 nike

我正在使用 selenium-webdriver.js 编写 Mocha 测试,并且仅在当前测试失败时才尝试截取屏幕截图。

在Mocha中,我可以获取当前的测试信息,例如标题和状态,如下所示:

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

但是selenium-webdriver.js用selenium-webdriver/testing封装了Mocha的接口(interface),并且原始的this.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

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

关于node.js - 在 selenium-webdriver.js 测试中获取测试标题和状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22643924/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com