Selenium 为什么base64屏幕截图在可通过电子邮件发送的数据块报告中是空白的?

Selenium 为什么base64屏幕截图在可通过电子邮件发送的数据块报告中是空白的?,selenium,base64,extentreports,selenium-extent-report,extent,Selenium,Base64,Extentreports,Selenium Extent Report,Extent,当我从本地机器执行时,我可以在故障场景的扩展报告中正确地看到屏幕截图。当我从Jenkins执行它并通过电子邮件发送扩展报告时,它是空白的。我试图在我的案例中使用base64。代码如下所示: public static String getBase64Screenshot() throws IOException { WebDriver driver1 = BaseConfig.setDriver(); Date oDate = new Date();

当我从本地机器执行时,我可以在故障场景的扩展报告中正确地看到屏幕截图。当我从Jenkins执行它并通过电子邮件发送扩展报告时,它是空白的。我试图在我的案例中使用base64。代码如下所示:

public static String getBase64Screenshot() throws IOException {
        WebDriver driver1 = BaseConfig.setDriver();
        Date oDate = new Date();
        SimpleDateFormat oSDF = new SimpleDateFormat("yyyyMMddHHmmss");
        String sDate = oSDF.format(oDate);
        String encodedBase64 = null;
        FileInputStream fileInputStream = null;
        File source = ((TakesScreenshot) driver1).getScreenshotAs(OutputType.FILE);
        String destination =System.getProperty("user.dir")+"/target/cucumber-reports/"+"Screenshot_" + sDate + ".png";
        File finalDestination = new File(destination);
        FileUtils.copyFile(source, finalDestination);

        try {
            fileInputStream =new FileInputStream(finalDestination);
            byte[] bytes =new byte[(int)finalDestination.length()];
            fileInputStream.read(bytes);
            encodedBase64 = new String(Base64.getEncoder().encode(bytes));

        }catch (FileNotFoundException e){
            e.printStackTrace();
        }
        return "data:image/png;base64,"+encodedBase64;
    }


@After(order = 1)
     public void afterScenario(Scenario scenario) {
      WebDriver driver1 = BaseConfig.setDriver();
     if (scenario.isFailed()) {
     String screenshotName = scenario.getName().replaceAll(" ", "_");
     System.out.println(screenshotName);
     try {
           Reporter.addScreenCaptureFromPath(getBase64Screenshot());
         }catch (IOException e) 

     }
     }