是否可以在范围报告之类的步骤之间获得诱惑报告的屏幕截图? [英] Is it possible to have screenshots of allure report between steps like extent report?

查看:81
本文介绍了是否可以在范围报告之类的步骤之间获得诱惑报告的屏幕截图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用魅力报告来生成测试报告.之前,我曾经使用范围报告.如您所知,在扩展区报告中,您可以按创建日志的顺序添加日志和屏幕截图,但在诱人的报告中,所有屏幕截图都将在步骤结束时显示.

I'm using allure report to generate a report for my tests. earlier I used to use extent report. as you know, in extent report you can add logs and screenshot in order of creating them but in allure reports, all the screenshots are going to be shown at the end of steps.

我的问题:是否可以在步骤之间显示屏幕截图?我想在每个步骤之后创建一个屏幕截图,并希望在正确的位置看到它们,而在报告的结尾处看到不是.感谢您的帮助:)

My Question: Is it possible to show the screenshots between steps? I want to create a screenshot after each step and I want to see them in the right place and not at the end of the report. Thanks for your help :)

推荐答案

您可以在以下步骤中通过截屏调用方法:

You can call method with taking screenshot in the step:

@Test(description = "Screenshot in Step")
public void screenshotInStepTest() {
    driver.get("https://www.google.com");
    step1();
    step2();
    step3();
}

@Step("Step 1")
public void step1(){
    System.out.println("step 1");
}
@Step("Step 2 with screenshot")
public void step2(){
    System.out.println("step 2");
    screenshot();
}
@Step("Step 3")
public void step3(){
    System.out.println("step 3");
}

@Attachment(value = "Screenshot", type = "image/png")
public byte[] screenshot() {
    return ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
}

更新:

import java.io.ByteArrayInputStream;
//...
@Step("Step 1")
public void step1(){
    //...

    Allure.addAttachment("Any text", new ByteArrayInputStream(((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES)));
}

报告:

这篇关于是否可以在范围报告之类的步骤之间获得诱惑报告的屏幕截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆