如何在黄瓜范围报告中添加文本文件

时间:2018-10-12 09:54:26

标签: selenium automation cucumber extentreports

我正在生成带有结果截图的黄瓜范围报告,但是现在我想在输出文件中添加文本文件,这可能吗?如果可以,请让我知道该怎么做。

谢谢。

2 个答案:

答案 0 :(得分:2)

创建并添加指向文本文件的链接:

test.info("<a href='path/text-file.txt'>click to view text</a>");

答案 1 :(得分:1)

是否要在报告中添加文本?如果是这样,只需在“ this.attach()”中添加要提供的文本即可,很简单

例如:-this.attach('Hello');

After(function (scenarioResult) {
        if(scenarioResult.isFailed()){
            try {
                let failedStep = '';
                scenarioResult.stepResults.map((stepResult) => {
                    if(stepResult.status === Status.FAILED){
                        failedStep = stepResult.step.name;
                    }
                });
               this.scenario.attach(JSON.stringify(report, ["name", "age"], '\t'));
//where name and age are keys in the json report
               return this.attach('Failed scenario is ' + scenarioResult.scenario.name + ' - ' + failedStep);
               
            }
            catch (error) {
                console.log(error);
            }
        }
    });