November 28, 2019

How to get a console output window in Visual studio to see real time logs

  November 28, 2019
In eclipse we do have console output window to show all the logs we write during tests.
All the strings written using System.out.println("Output is "+res) will be displayed in the Console window in real time as below.


This is a very useful functionality automation testers uses when running or debugging a test.

Can we have the same functionality in Visual Studio also? Simple answer is Yes, But we have to create the test as a Console Application project.

But in real scenarios we will be creating class library project for the easiness of automation scripts and class library projects doesn't support the console view of output.

So if we are running a test directly from the test explorer we have no option to see the real time output in the console (Still output can be seen in output window when execution is completed ).

But if we still need to see the real time console output, we may have to go for the debugging mode of execution.

To enable this we need to turn on the immediate output window. Follow below step in Visual studio to do this.

  • Go to Tools-> Options
  • Search for Output
  • Enable the Redirect all output window checkbox


We can use Debug.Write("Test 1") to write string to immediate window and it will be shown as below.


The same output will be shown in output section of test explorer also.


If we click on the Output link we can see the same logs.


This window can be seen only after the test execution.

logoblog

Thanks for reading How to get a console output window in Visual studio to see real time logs

Previous
« Prev Post

No comments:

Post a Comment

Bookmark this website for more workarounds and issue fixes.

Verify Zip file contents without extracting using C# + Selenium

While doing automation testing, we may get a scenario where we need to download a zip file and to validate the contents inside it. One way t...