0

我尝试使用下面的代码将失败测试的屏幕截图发送到 reportPortal,但它对我不起作用。有人可以在这里帮忙吗

public ReportPortalMessage failedScrenshot(String methodName) 
    {
        ReportPortalMessage message = null;
        String time = pg.subGrpUnique_monthdate();
        File srcfile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
        java.util.Date d= new java.util.Date();
        try
        {
                org.apache.commons.io.FileUtils.copyFile(srcfile, new File("./ScreenShots/"+d.toString().replace(":", "_")+".png"));                               message = new ReportPortalMessage(srcfile, rp_message);
            LOGGER.info("Screenshot taken.");
        }
        catch (IOException e)
        {
            e.printStackTrace();
            LOGGER.info("Unable to take screenshot.");
        }
         LOGGER.info(message);
         return message;   
    }
4

1 回答 1

0

有些示例完全符合您的要求:

对于第一个示例屏幕截图将出现在@AfterMethod测试视图 方法视图

对于后一个示例屏幕截图将出现在相同的测试方法中: 测试视图 方法视图

于 2021-05-25T13:07:14.637 回答