gpt4 book ai didi

java - 是否可以在范围报告等步骤之间获得诱惑报告的屏幕截图?

转载 作者:太空宇宙 更新时间:2023-11-03 19:42:45 26 4
gpt4 key购买 nike

我正在使用 allure 报告来生成测试报告。早些时候我曾经使用范围报告。如您所知,在范围报告中,您可以添加日志和屏幕截图以创建它们,但在诱惑报告中,所有屏幕截图都将显示在步骤的末尾。

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

最佳答案

您可以在步骤中调用带有截图的方法:

@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)));
}

报告: enter image description here

关于java - 是否可以在范围报告等步骤之间获得诱惑报告的屏幕截图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60337513/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com