【问题标题】:Base64 image screenshot in extent report is showing garbage value on clicking the screenshot in the report范围报告中的 Base64 图像屏幕截图在单击报告中的屏幕截图时显示垃圾值
【发布时间】:2019-03-29 04:30:26
【问题描述】:

硒范围报告中的Base64图像在单击报告中的图像后无法正确显示。

搜索了各种来源以获取问题解决方案,但在任何地方都找不到答案

//POM.xml代码中的依赖:-

<dependency>
 <groupId>com.aventstack</groupId>
 <artifactId>extentreports</artifactId>
 <version>3.1.5</version>
</dependency>

//ExtentReporterListener 代码:-

public synchronized void onTestFailure(ITestResult result) {
    System.out.println((result.getMethod().getMethodName() + " failed!"));
    test.get().fail("Test failed due to below error");
    try {
        test.get().fail(result.getThrowable(), MediaEntityBuilder.createScreenCaptureFromPath(TestUtil.getScreenshotExtent()).build());
    } catch(IOException e) {
        System.err.
        println("Exception thrown while updating test fail status " + Arrays.toString(e.getStackTrace()));
    }
    test.get().getModel().setEndTime(getTime(result.getEndMillis()));
}

//截屏代码:-

public class TestUtil {
    public static String getScreenshotExtent() {
        String Base64StringofScreenshot = "";
        File src = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
        byte[] fileContent;
        try {
            fileContent = FileUtils.readFileToByteArray(src);
            Base64StringofScreenshot = "data:image/png;base64," + Base64.getEncoder().encodeToString(fileContent);
        } catch(IOException e) {
            e.printStackTrace();
        }
        return Base64StringofScreenshot;
    }
}

有人可以帮忙解决这个问题并在点击后在范围报告中正确显示图像吗?

【问题讨论】:

    标签: java selenium base64 extentreports selenium-extent-report


    【解决方案1】:

    您能告诉我您在哪个浏览器中运行此自动化套件吗?

    例如:您在 windows 64 位操作系统中使用 Chrome 浏览器,那么您需要检查您下载的 chromedriver.exe,即 32 位或 64 位。如果您使用的是 32 位驱动程序,那么这类问题来了。

    如果您仍然没有找到任何解决方案,请告诉我。

    【讨论】:

    • 我有 64 位的 windows 操作系统,但我认为只有 1 个支持 32 位和 64 位操作系统的 chromedriver.exe。我正在使用最新版本的 chromedriver.exe,因为它支持我当前的 chrome 浏览器。有没有其他方法可以解决这个问题?
    猜你喜欢
    • 1970-01-01
    • 2021-08-22
    • 2018-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-02
    • 1970-01-01
    相关资源
    最近更新 更多