Logging errors with Selenium WebDrive in C #

1

Good evening!

I'm organizing my test suite and looking for the best ways to create an error report when a test fails. I have already implemented a log in .txt with the name of the test that is executed (using TestContext), the test execution time, its status (Passed, error, timeout ...), and saving prints if the test fails.

However, if the test fails, you would also like to save the reason for the error, as well as Visual Studio points out when debugging, or the reason for failure in the test suite itself appears. The case is that I will make a service run the dawn tests, and I will not have access to the written reasons for the failure.

I thought of some possible solutions, I just did not implement them because I believe there are better ways. For example, one of the possibilities I imagined was to handle all tests with try / catch, and save the error inside the catchs.

I'm using the latest stable version of Selenium WebDriver in a C # project, with structure based on Microsoft.VisualStudio.TestTools.UnitTesting. Thank you in advance!

    
asked by anonymous 27.08.2015 / 23:51

1 answer

1

I think your problem would not be to log the Selenium errors themselves, but how to write the errors of your unit tests.

If you are using NUnit, an option for what you want to do is the Nunit Addins API, where you can write the exceptions of a test to a separate file for later reference.

Depending on the NUnit version, there are other alternatives yet. If you are using NUnit 3.x it is possible to do it one way and with NUnit 2.x is possible to do another . Unfortunately, the documentation for these cases seemed very precarious, but it's worth checking.

    
28.08.2015 / 21:10