Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp cannot be configured in ExtentSparkReporter #206

Open
dcdraper opened this issue Jan 10, 2024 · 16 comments
Open

Timestamp cannot be configured in ExtentSparkReporter #206

dcdraper opened this issue Jan 10, 2024 · 16 comments

Comments

@dcdraper
Copy link

I want to show seconds in the ExtentReport, but there is no "TimeStampFormat" option to configure that, even though the documentation and codebase (spark-config.json) indicates that it is possible:

Code running in Visual Studio
image

[extentreports-csharp]/[config]/spark-config.json in GitHub
image

ExtentReport
image

@namilkimfree
Copy link

did you loader json config?


var yourConfigPath= Path.Combine(@"..\..\..\..\", @"config\spark-config.json");
            var spark = new ExtentSparkReporter("Spark.html");
            spark.LoadJSONConfig(yourConfigPath);

check please.

@dcdraper

@dcdraper
Copy link
Author

@namilkimfree
Thank you for those instructions to load the config file. I successfully loaded and manipulated other settings via the spark-config.json file like theme, timelineEnabled, documentTitle and reportName. However the timestamps do not change regardless of what I change the format to in spark-config.json.

I want to change the timestamp format for each step of a test, underlined in my screenshot in my original post. We are not getting valuable data to see how many seconds it took to get to the next step, etc. Modifying the timeStampFormat in spark-config.json does not change the format anywhere at all on the report.

@sudheshg
Copy link
Contributor

sudheshg commented Jan 31, 2024

@namilkimfree Thank you for those instructions to load the config file. I successfully loaded and manipulated other settings via the spark-config.json file like theme, timelineEnabled, documentTitle and reportName. However the timestamps do not change regardless of what I change the format to in spark-config.json.

I want to change the timestamp format for each step of a test, underlined in my screenshot in my original post. We are not getting valuable data to see how many seconds it took to get to the next step, etc. Modifying the timeStampFormat in spark-config.json does not change the format anywhere at all on the report.

The timeStamp property was not serialized and was not used anywhere in the extent report library, and I think it should be removed from the documentation.

There is a possibility of datetime conflict issues with the multicultural provider. For example, if my local instance culture is set to en-US, if I pass "dd/MM/yyyy hh:mm:ss" (31/1/2024), it won't work. This could be a reason it is not implemented, I guess.

@dcdraper
Copy link
Author

@sudheshg The seconds do display in other areas in that screenshot above. Perhaps, if not configurable, the steps could use that same format as is already used in those other places?
Again we are missing valuable log information here and may need to add our own timestamp each time we write to the log, which defeats the purpose a little of having a reporter like ExtentReports. 😁

@sudheshg
Copy link
Contributor

sudheshg commented Feb 1, 2024

@sudheshg The seconds do display in other areas in that screenshot above. Perhaps, if not configurable, the steps could use that same format as is already used in those other places? Again we are missing valuable log information here and may need to add our own timestamp each time we write to the log, which defeats the purpose a little of having a reporter like ExtentReports. 😁

Then need to pass the expected TimeZone info in the config file to match the timeStampformat.

@dcdraper
Copy link
Author

dcdraper commented Feb 2, 2024

@sudheshg Then need to pass the expected TimeZone info in the config file to match the timeStampformat.

I do not know what this means. There is no timezone option in the config file.

@SerreauFrederic
Copy link

I have the same problem, I'm on a French machine, and I don't have the seconds displayed.

I tested with the json configuration but it doesn't change anything, and no possibility in C#.

Is there a solution ?

image

@sharon-sharonmuffins
Copy link

As we are using the same report in different time zones the report shows different time formats according to the user system time format .
We need to set a specific time format , I tried using json-config but there is no change.
This issue is of high importance , could you please resolve this and give us an option to set format.

@SerreauFrederic
Copy link

For workaround the issue, I did this solution :

I set my date in the details log with a separator (for example : TIME )

string myText = "my log line";
myText = $"{DateTime.Now:HH:mm:ss}_TIME_{myText}";

Test.Log(status, myText , media); // Test is ExtentTest object, media is optionnal

in config of ExtentSparkReporter, I set a json script like this :

ExtentSparkReporter extentSparkReporter = new ExtentSparkReporter(path);

extentSparkReporter.Config.JS = @"
                        var elements = document.getElementsByClassName('event-row')

                        for (let i = 0; i < elements.length; i++) {
                            var cellules = elements[i].getElementsByTagName('td');
                            var split = cellules[2].innerHTML.split('_TIME_');
                            var timestamp = split[0].replace('\n', '');
                            cellules[1].innerHTML = timestamp;
                            cellules[2].innerHTML = split[1];    
                        }";

at the end, my timestamp has seconds :)

image

@sharon-sharonmuffins
Copy link

Thank you for the work around , the issue I am facing right now is
In my report generated I see that it is picking up the date time of the system time
I need to fix the time stamp which should not change with Time zone change
ReportImage
Please help me fix the time stamp to be consistent across all timezones

@SerreauFrederic
Copy link

You can use DateTime.UtcNow

@namilkimfree
Copy link

@dcdraper ExtentReports/Views/Spark/Partials/Log.cshtml at line19
The TimeStamp value is hardcoded as a short. In order to modify it, you need to read the config value and format it.

@dcdraper
Copy link
Author

@namilkimfree Thanks for responding again, but I do not have any idea how I can read or format it. There is no config option for Timestamp. Have you done this? Do you have an example or sample code?

@anshooarora
Copy link
Member

Sorry for the delay, currently looking into this.

@anshooarora
Copy link
Member

The fix in this branch fixes the issue. There are several fixes made to the template due to which, I will need to do further testing + write tests as necessary.

@dcdraper
Copy link
Author

dcdraper commented May 10, 2024

@anshooarora
Thank you for working on this! I was curious so I tried the fix branch today, and it is giving me what we desperately needed.

I did notice a couple things I did not quite expect...

  1. Removing the date part of the format also removes it from the header, which does not matter to me but seems different than how it used to work. If you look at my original screenshot you can see the header has the date part but the Timestamp column does not:
    image

  2. Using the date part adds it back to the header but makes the Timestamp too long to fit on one line; the report does not auto-adjust for that:
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants