extentreports-csharp icon indicating copy to clipboard operation
extentreports-csharp copied to clipboard

Report name issue.

Open dod0o opened this issue 7 years ago • 8 comments

Hi, the ExtentManager.cs class has the private static ExtentHtmlReporter getHtmlReporter() method which instantiates the htmlReporter = new ExtentHtmlReporter(ReportLocation);

The ReportLocation is a string path to the location and name of the report. Ex: D:\Projects\MyProject\ExtentReports\my_report_name_dd-MM-yyyy.html.

This worked perfectly on version 2, but after upgrading to v4 the html report is created with the name index.html instead of the name I give it. Ex: D:\Projects\MyProject\ExtentReports\index.html

Also there are two distinct html files created, index.html and dashboard.html, instead of a single report file.

How can this issue be solved? I need to give my report a specific name.

Thank you.

dod0o avatar Feb 08 '19 13:02 dod0o

can you specify the exact version and the .net framework version you are using?

bvizureanu avatar Feb 08 '19 13:02 bvizureanu

NET 4.7.2 ExtentReports 4.0.2 and 4.0.3 both have the same behavior.

dod0o avatar Feb 08 '19 13:02 dod0o

@dod0o This is the expected behavior with the version4 HtmlReporter. It creates upto 4 files depending upon the attributes that are created. This is also true for all new version4 reporters, to maximize performance and obviously to keep each file focused on its specific tasks.

If you would like the old behavior, use the version3 port of HtmlReporter:

var v3html = new ExtentV3HtmlReporter();

anshooarora avatar Feb 08 '19 17:02 anshooarora

^ With that being said and with version-4 reporters, instead of specifying the file name, you now need to specify the directory name with your timestamps and all files will be created likewise.

anshooarora avatar Feb 08 '19 17:02 anshooarora

So, there's no way to change the file name of the report?

ArCiGo avatar Mar 21 '22 17:03 ArCiGo

So, there's no way to change the file name of the report?

While there is no way to rename this file directly from Extent library, I renamed this file using this simple piece of code.

System.IO.File.Move(oldNameFullPath, newNameFullPath);

This solved my purpose. Hope this helps.

jaideep-dhumal avatar Apr 06 '22 13:04 jaideep-dhumal

Hi @jaideep-dhumal Where to use this line of code? When i put in [AfterTestRun] it doesnt works?

venkat22210 avatar Dec 22 '22 08:12 venkat22210

I have written this line of code after publishing result to Extent file.

Example:

extent.Flush(); if (!File.Exists(newNameFullPath)) { File.Move(oldNameFullPath, newNameFullPath); }

Hope this helps.

jaideep-dhumal avatar Dec 22 '22 15:12 jaideep-dhumal