[英]Is it possible to have screenshots of allure report between steps like extent 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.