簡體   English   中英

是否可以在范圍報告等步驟之間有誘惑報告的屏幕截圖?

[英]Is it possible to have screenshots of allure report between steps like extent report?

我正在使用allure report 為我的測試生成報告。 早些時候我曾經使用范圍報告。 如您所知,在范圍報告中,您可以按創建它們的順序添加日志和屏幕截圖,但在魅力報告中,所有屏幕截圖都將在步驟結束時顯示。

我的問題:是否可以在步驟之間顯示屏幕截圖? 我想在每個步驟之后創建一個屏幕截圖,我想在正確的位置而不是在報告的末尾看到它們。 在此處輸入圖像描述 在此處輸入圖像描述 謝謝你的幫助:)

您可以在步驟中通過截圖調用方法:

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

報告: 在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM