Selenium Jenkins中的数据块报告显示了附加屏幕截图的空白图标

Selenium Jenkins中的数据块报告显示了附加屏幕截图的空白图标,selenium,jenkins,extentreports,Selenium,Jenkins,Extentreports,我已经为我的项目生成了一个可运行的jar,并通过jenkins在其他机器上运行它。 Jar文件成功执行并生成扩展数据块报告, 但是屏幕截图上有一个空白图标 我在谷歌上搜索过,但没有找到任何相关的解决方案来解决我的问题 我正在使用Intellij IDE并使用“在浏览器中打开”选项打开数据块报告。 当有两个以上的屏幕截图(如上面的情况)与扩展报告一起附加时,它将显示空白图标,并在新选项卡中打开图像时显示错误。 (通过进入系统中实际保存数据块报告的文件夹打开数据块报告时,该报告按预期工作)

我已经为我的项目生成了一个可运行的jar,并通过jenkins在其他机器上运行它。 Jar文件成功执行并生成扩展数据块报告, 但是屏幕截图上有一个空白图标

我在谷歌上搜索过,但没有找到任何相关的解决方案来解决我的问题

  • 我正在使用Intellij IDE并使用“在浏览器中打开”选项打开数据块报告。 当有两个以上的屏幕截图(如上面的情况)与扩展报告一起附加时,它将显示空白图标,并在新选项卡中打开图像时显示错误。 (通过进入系统中实际保存数据块报告的文件夹打开数据块报告时,该报告按预期工作)

我的代码:

       @BeforeTest
            public void setExtent() {
                extent = new ExtentReports(System.getProperty("user.dir")+ "/test-output/Login.html", true);
                System.out.println("KKKKKKK");
                extentTest = extent.startTest("Start the Execution");
                extent.addSystemInfo("Host Name", "Live Contract");
                extent.addSystemInfo("User Name", "Shivam Goyal");
                extent.addSystemInfo("Environment", "Develop");
                extentTest.log(LogStatus.INFO, "Test Execution started");
        
            } 
    
       
    
    public static String getScreenshot(WebDriver driver, String screenshotName) {
                String dateName = new SimpleDateFormat("ddMMyyyyhhmmss").format(new Date());
                TakesScreenshot ts = (TakesScreenshot) driver;
                File src = ts.getScreenshotAs(OutputType.FILE);
                String path = System.getProperty("user.dir")+ "/test-output/"+ screenshotName + dateName + ".png";
                File destination = new File(path);
        
                try {
                    FileUtils.copyFile(src, destination);
                }
                catch(IOException e){
                    System.out.println("Capture Failed" +e.getMessage());
                }
                return path;
            }
    
    @Test
        public void openURL() throws IOException, InterruptedException, HeadlessException, UnsupportedFlavorException {
            System.out.println("test openWeb");
    
            extentTest = extent.startTest("LC1_1.1 - Verify the Login Panel of \"Berater\".");
    
            try {
                //Accept All cookies
                driver.findElement(By.className(property.getProperty("LiveContractCookies"))).click();
    
    
                //Test case LC1_1.1 Open the given URL in Browser (Aufruf der entsprechenden URL im Browser)
    
                boolean Homescreen = driver.findElement(By.name(property.getProperty("BeraterLoginPanelName1"))).isDisplayed();
                Thread.sleep(3000);
    
                Assert.assertTrue(Homescreen);
            } catch (NoSuchElementException e) {
                e.printStackTrace();
            }
        }
    
        @Test
        public void checkEntryFields() throws InterruptedException {
            extentTest = extent.startTest("LC1_1.2 - Verify the Entry fields on Berater's login panel");
            try {
                driver.findElement(By.className(property.getProperty("LiveContractCookies"))).click();
    
                WebElement username = driver.findElement(By.name(property.getProperty("username_fieldName")));
                WebElement password = driver.findElement(By.name(property.getProperty("password_fieldName")));
    
    
                username.click();
                username.sendKeys("Test123");
                password.click();
                password.sendKeys("9876554");
                Thread.sleep(1000);
                System.out.println(username.getText());
    
                String usnm = username.getAttribute("value");
                String pass = password.getAttribute("value");
    
                System.out.println("Something happening");
    
                Assert.assertEquals("Test123", usnm);
                Assert.assertEquals("98765", pass);
            }
            catch(Exception e){
                e.printStackTrace();
            }
    
        }
    
    
        @AfterMethod
        public void tearDown(ITestResult result) {
            if(result.getStatus() == ITestResult.FAILURE){
                extentTest.log(LogStatus.FAIL, "Test Case Failed is" +result.getName());
                extentTest.log(LogStatus.FAIL, "Test Case Failed is" +result.getThrowable());
    
                String screenshotPath = Login.getScreenshot(driver, result.getName());
                extentTest.log(LogStatus.FAIL, extentTest.addScreenCapture(screenshotPath));
            }
            else if(result.getStatus() == ITestResult.SKIP){
                extentTest.log(LogStatus.SKIP, "Test Case Skipped is "+result.getName());
            }
            else if(result.getStatus() == ITestResult.SUCCESS){
                extentTest.log(LogStatus.PASS, "Test Case Passed is "+result.getName());
            }
    
                extent.endTest(extentTest);
                //extent.flush();
                driver.quit();
                //tempDriver.quit();
                //tempDriver.quit();
    
    
        }
    
        @AfterTest
        public void endReport() {
            try{
                extent.flush();
            }
            catch(Exception e){
                e.getMessage();
            }
    
            //extent.close();
        }

听起来好像无法从报告中访问路径。你检查了文件系统,以确保图像在你期望的位置,并且得到了正确的许可?是的,我想,我试图将扩展报告和屏幕截图保存在同一个文件夹中,但这还不够。我是否需要在Jenkins中添加任何文件夹或其他设置,或者这是我的类中的错误?