Save output messages from Console.WriteLine and show them in ExtentReport html result file

115 Views Asked by At

My selenium tests are printing a lot output messages after each action made. For example after each click on an element, it prints a output message like Click on Element: xyz

When the automation test is done, the TestExplorer in Visual Studio look like this:

TestExplorer Screenshot

I added recently ExtentReport to my selenium project.

And i want to add all output messages, that can be seen in the TestExplorer, to the ExtentReport output file.

Is there a way to do that? Id like to define a START point, from where it should start storing all "Console.WriteLine" output messages and at the end of the test, it should push all stored output messages into the ExtentReport html file

My current TestPlan class can be seen below.

  • In Row 40, i use the "CreateTest" for extentReport.
  • In Row 42 the TestCase CheckForErrorLogs is called which contains all selenium action methods to navigate through the pages and where each action is printing the output messages.
  • In Row 48, all TestData are being deleted and also the extent.Flush(); is being called to create the html file.

Image of the TestPlan class

Is there a way to start storing all Console.WriteLine message before Row 42 and then to push all the stored Console.WriteLine messages into the extentReport before Row 48 so they are visible in the html?

It was a bit hard to explain what i want, so i apologize if the question is a bit too detailed or not very clear. If there are any questions, please let me know.

0

There are 0 best solutions below