简体   繁体   中英

How to remove few items from Extent Report

I used Extent Reporting Framework ( https://www.extentreports.com/ ) to generate a nice-looking report in my java / springboot app. There are a few unnecessary items that I would like to remove. Here is my report:-

在此处输入图像描述

In the Dashboard view, I want to remove Log Events. How to remove it? Also in the list view, there are 2 items marked. It looks like time and #test-id=1. I want to remove them. I have no idea what are those? Please let me know how to remove them?

I was able to remove/hide any Element from extent report using below code. you can add the below line to your extent report class and locate the element that you want to remove/hide from the report being generated.

"ExtentSparkReporterObject.config().setJs("document.getElementsByClassName('Class_Name_Of_Element_Needed_to_Be_Removed')[0].style.setProperty('display','none');");"

My Actual code

public class ExtentReport {
     static ExtentReports extent;
        final static String filePath = "Report.html";
        static Map<Integer, ExtentTest> extentTestMap = new HashMap<Integer, ExtentTest>();

        public synchronized static ExtentReports getReporter() {
            if (extent == null) {
                ExtentSparkReporter html = new ExtentSparkReporter("Report.html");
                html.config().setDocumentTitle("Web Automation Test Result");
                html.config().setReportName("WBHM");
                html.config().setTheme(Theme.DARK);
                html.config().enableOfflineMode(true);
                html.config().thumbnailForBase64();
                html.config().setTimelineEnabled(false);
                html.config().setJs("document.getElementsByClassName"
                        + "('col-md-6')[0].style.setProperty('display','none');");          
                extent = new ExtentReports();
                extent.attachReporter(html);
                extent.setSystemInfo("OS", "Windows10");
                extent.setSystemInfo("Browser", "Chrome");         
            }
            return extent;
        }
        
        public static synchronized ExtentTest getTest() {
            return (ExtentTest) extentTestMap.get((int) (long) (Thread.currentThread().getId()));
        }

        public static synchronized ExtentTest startTest(String testName, String desc) {
            ExtentTest test = getReporter().createTest(testName, desc);
            extentTestMap.put((int) (long) (Thread.currentThread().getId()), test);
            return test;
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM