【发布时间】:2022-04-08 18:59:11
【问题描述】:
我有一个具有以下结构的 webdriverio 项目。 e2e/ 实用程序/pUtil.js 报告/截图 眼镜 wdio.config.js
我在 pUtil.js 中有以下内容
static takeScreenshot(name, failure = false, test) {
const path = './e2e/report/screenshot/';
let fileName = '';
if (!fs.existsSync(path)) {
fs.mkdirSync(path, { recursive: true });
}
if (failure) {
fileName = name + '_fail';
}
fileName = fileName.replace(/ /g, '_') + '.png';
browser.saveScreenshot(path + fileName);
const data = fs.readFileSync(`${path}${fileName}`);
reporter.sendFileToTest(test, 'INFO', fileName, data);
}
我的项目配置为同时适用于魅力和报告门户报告。 当测试失败时,截图成功添加到诱惑报告而不是报告门户。
********* FILE NAME IN **********./e2e/report/screenshot/should_allow_us_fail.png
[2021-09-23T01:20:52.483Z] [0-0] ************ outputFile::./e2e/report/screenshot//should_allow_us_fail.png
[2021-09-23T01:20:52.483Z] [0-0] 2021-09-23T01:20:51.026Z ERROR @wdio/sync: Error: ENOENT: no such file or directory, open './e2e/report/screenshot/should_allow_us_fail.png'
[2021-09-23T01:20:52.483Z] [0-0] at Object.openSync (fs.js:457:3)
[2021-09-23T01:20:52.483Z] [0-0] at Object.readFileSync (fs.js:359:35)
有人可以指出我在这里缺少什么。
【问题讨论】:
标签: javascript selenium jenkins webdriver-io