【发布时间】:2019-03-14 18:10:36
【问题描述】:
我可以成功将屏幕截图添加到诱惑报告中,但出现以下异常错误:
错误:
TypeError: Cannot read property 'currentStep' of undefined
at Allure.addAttachment (/Users//xxx/xxx/xxx/node_modules/allure-js-commons/index.js:86:45)
at Allure.createAttachment (/Users/xxx/xxx/xxx/node_modules/allure-js-commons/runtime.js:48:29)
at /Users/xxx/xxx/xxx/lib/class/class-name.js:30:20
at process._tickCallback (internal/process/next_tick.js:68:7)
类:
browser.takeScreenshot().then(function (png) {
allure.createAttachment(title, new Buffer(png, 'base64'));
}).catch((error: any) => console.log(error));
【问题讨论】:
-
您是遇到错误还是只有异常?你在你的项目中使用了
currentStep吗? -
只是例外。我似乎已经通过添加 try, catch 来解决它。这是正确的方法吗?
try { await browser.takeScreenshot().then(function (png) { allure.createAttachment(title, new Buffer(png, 'base64')); }); } catch (e) { console.log('Error caught'); } -
我没有使用
currentStep,它来自createAttachment吗? -
@user 我猜您的脚本仍在从您发布的评论中的代码中打印出
Error caught?您的 try/catch 将简单地隐藏异常,因为您不再打印它。如果你愿意,你可以用同样的方式构建你的 .then/.catch 。最好尝试找出发生该异常的原因。您是否在代码中的其他任何地方成功使用了任何其他takeScreenshot或allure.createAttachment? -
这是我使用
takeScreenshot和allure.createAttachment的地方
标签: protractor mocha.js allure