【问题标题】:java.io.IOException: Media was not found error while attaching a screenshot to extent reportjava.io.IOException:将屏幕截图附加到范围报告时未找到媒体错误
【发布时间】:2020-04-20 03:01:24
【问题描述】:

当我尝试附加在 selenium 项目中捕获并保存的屏幕截图以扩展测试自动化报告时,它给了我一个错误,提示 java.io.IOException: Media is not found at [C:\Users \Suresh\git\BasicFuncTesting\test-output\Screenshot\imageOneBrokenTest.png]

我的图片路径如下。

String imagePath = "C:\\Users\\Suresh\\git\\BasicFuncTesting\\test-output\\Screenshot\\imageOneBrokenTest.png";

我使用了以下两种方法来附加此屏幕截图,但两种方法都给我同样的错误。

logger.addScreenCaptureFromPath(imagePath, "Fail");

logger.fail("Screenshot", MediaEntityBuilder.createScreenCaptureFromPath(imagePath).build());

这里的 logger 是 ExtentTest 对象。

【问题讨论】:

  • 尝试使用绝对路径。

标签: selenium automation ioexception extentreports selenium-extent-report


【解决方案1】:

通过如下设置变量值,我能够成功地使用捕获的屏幕截图生成我的范围报告。

    String imagePath = "C:/Users/Suresh/git/BasicFuncTesting/BasicFuncTesting/test-output/Screenshot/1587494732758.png";

try {
           logger.fail("Screenshot", MediaEntityBuilder.createScreenCaptureFromPath(imagePath).build());                    
        } catch (Exception e) {         
            e.printStackTrace();
            }

【讨论】:

    猜你喜欢
    • 2021-10-15
    • 1970-01-01
    • 2019-08-16
    • 2020-04-12
    • 2018-11-28
    • 2021-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多