在步骤失败后,我正在尝试截屏:
const { After } = require('cucumber');
After(function (scenario) {
if (scenario.result.status ==='failed') {
var world = this;
return browser.takeScreenshot().then(function(screenShot, error) {
if (!error) {
world.attach(screenShot, "image/png");
}
});
}
});
它显示浏览器错误: ReferenceError:未定义浏览器
答案 0 :(得分:1)
尝试以下方法。确保匹配根据您的用法匹配的webdriver var名称。
var {After, Status} = require('cucumber');
After(function (testCase) {
var world = this;
if (testCase.result.status === Status.FAILED) {
// driver- update this with the correct webDriver variable
return driver.takeScreenshot().then(function(screenShot) {
// screenShot is a base-64 encoded PNG
world.attach(screenShot, 'image/png');
});
}
});