Using Log4Net with Selenium

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Using Log4Net with Selenium

superfreak3
This post has NOT been accepted by the mailing list yet.
Hi all, I'm trying to add some logging to my Selenium C# WebDriver tests, but can't seem to get it to write anything to a log file.

I've pretty much followed this...

https://www.youtube.com/watch?v=8SPJkCdp9vQ

When I run a test with a sample Debug message nothing is written to the file I specified in App.Config.  Since I believe my Selenium project is an MS Test type project, it didn't have an App.config file so I added it and the only items currently contained within are associated with log4net.

I hope someone who has or is using Selenium can help get me logging in my [TestMethod].

Thanks so much in advance!

Reply | Threaded
Open this post in threaded view
|

Re: Using Log4Net with Selenium

superfreak3
I was able to get everything to work by changing the Copy to Output Directory property to Copy always.  Once the app.config file was actually present, the log was created and updated as hoped.

Now if I can only get the Microsoft Test Tools unit test exception for my web app tests, I'll be all set, but that is, of course, outside the scope of this forum.
Reply | Threaded
Open this post in threaded view
|

Re: Using Log4Net with Selenium

superfreak3
This post was updated on .
In reply to this post by superfreak3
I noticed something strange that has happened since adding logging with log4Net.  When exceptions occur, they are caught and written as desired to the log.  However, running via both mstest and Visual Studio 2015, despite the fact exceptions occur, the tests are still seen as successful.

I verified it has something to do with the logging additions as I got the previous version from TFS and I'm able to run the tests in Visual Studio where the problematic tests do indicate failure.

I can provide a file that shows the steps I followed to get logging to work.  I'm not sure if the addition of an app.config file causes this to be handled differently within the testing framework or handling in Visual Studio.

Any help would be greatly appreciated!!
Reply | Threaded
Open this post in threaded view
|

Re: Using Log4Net with Selenium

superfreak3
Here's the file I spoke of...
 
 

On Tue, Jan 5, 2016 at 9:01 PM, superfreak3 [via Apache Logging] <[hidden email]> wrote:
I noticed something strange that has happened since adding logging with log4Net.  When exceptions occur, they are caught and written as desired to the log.  However, running via both mstest and Visual Studio 2015, despite the fact exceptions occur, the tests are still seen as successful.

I verified it has something to do with the logging additions as I got the previous version from TFS and I'm able to run the tests in Visual Studio where the problematic tests do indicate failure.

I've attached a file that shows the steps I followed to get logging to work.  I'm not sure if the addition of an app.config file causes this to be handled differently within the testing framework or handling in Visual Studio.

Any help would be greatly appreciated!!

Selenium_and_Log4Net_Logging.docx


If you reply to this email, your message will be added to the discussion below:
http://apache-logging.6191.n7.nabble.com/Using-Log4Net-with-Selenium-tp59639p60848.html
To unsubscribe from Using Log4Net with Selenium, click here.
NAML


Selenium and Log4Net Logging.docx (204K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Using Log4Net with Selenium

superfreak3
In reply to this post by superfreak3
I've found that sending exceptions to the log in the catch block will cause the test to be seen as successful overall.  How can I also set the test result for Selenium in that block.
 
pseudo code:  Set MyTestResult = Failed. ??

On Tue, Jan 5, 2016 at 10:00 PM, mawa316 . <[hidden email]> wrote:
Here's the file I spoke of...
 
 

On Tue, Jan 5, 2016 at 9:01 PM, superfreak3 [via Apache Logging] <[hidden email]> wrote:
I noticed something strange that has happened since adding logging with log4Net.  When exceptions occur, they are caught and written as desired to the log.  However, running via both mstest and Visual Studio 2015, despite the fact exceptions occur, the tests are still seen as successful.

I verified it has something to do with the logging additions as I got the previous version from TFS and I'm able to run the tests in Visual Studio where the problematic tests do indicate failure.

I've attached a file that shows the steps I followed to get logging to work.  I'm not sure if the addition of an app.config file causes this to be handled differently within the testing framework or handling in Visual Studio.

Any help would be greatly appreciated!!

Selenium_and_Log4Net_Logging.docx


If you reply to this email, your message will be added to the discussion below:
http://apache-logging.6191.n7.nabble.com/Using-Log4Net-with-Selenium-tp59639p60848.html
To unsubscribe from Using Log4Net with Selenium, click here.
NAML


Reply | Threaded
Open this post in threaded view
|

RE: Using Log4Net with Selenium

Jim Scott-8
try
{
     //test
}
catch(Exception ex)
{
      log.Error(ex); // log your exception
      throw; // allow exception to continue
}

From: [hidden email]
Sent: ‎1/‎6/‎2016 6:57 AM
To: [hidden email]
Subject: Re: Using Log4Net with Selenium

I've found that sending exceptions to the log in the catch block will cause the test to be seen as successful overall.  How can I also set the test result for Selenium in that block.
 
pseudo code:  Set MyTestResult = Failed. ??

On Tue, Jan 5, 2016 at 10:00 PM, mawa316 . <[hidden email]> wrote:
Here's the file I spoke of...
 
 

On Tue, Jan 5, 2016 at 9:01 PM, superfreak3 [via Apache Logging] <[hidden email]> wrote:
I noticed something strange that has happened since adding logging with log4Net.  When exceptions occur, they are caught and written as desired to the log.  However, running via both mstest and Visual Studio 2015, despite the fact exceptions occur, the tests are still seen as successful.

I verified it has something to do with the logging additions as I got the previous version from TFS and I'm able to run the tests in Visual Studio where the problematic tests do indicate failure.

I've attached a file that shows the steps I followed to get logging to work.  I'm not sure if the addition of an app.config file causes this to be handled differently within the testing framework or handling in Visual Studio.

Any help would be greatly appreciated!!

Selenium_and_Log4Net_Logging.docx


If you reply to this email, your message will be added to the discussion below:
http://apache-logging.6191.n7.nabble.com/Using-Log4Net-with-Selenium-tp59639p60848.html
To unsubscribe from Using Log4Net with Selenium, click here.
NAML




View this message in context: Re: Using Log4Net with Selenium
Sent from the Log4net - Users mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Using Log4Net with Selenium

superfreak3
I was just about to replay that it was as easy as throw.  Thank you so much for the replies!

On Wed, Jan 6, 2016 at 9:40 AM, Jim Scott-8 [via Apache Logging] <[hidden email]> wrote:
try
{
     //test
}
catch(Exception ex)
{
      log.Error(ex); // log your exception
      throw; // allow exception to continue
}

From: [hidden email]
Sent: ‎1/‎6/‎2016 6:57 AM
To: [hidden email]
Subject: Re: Using Log4Net with Selenium

I've found that sending exceptions to the log in the catch block will cause the test to be seen as successful overall.  How can I also set the test result for Selenium in that block.
 
pseudo code:  Set MyTestResult = Failed. ??

On Tue, Jan 5, 2016 at 10:00 PM, mawa316 . <[hidden email]> wrote:
Here's the file I spoke of...
 
 

On Tue, Jan 5, 2016 at 9:01 PM, superfreak3 [via Apache Logging] <[hidden email]> wrote:
I noticed something strange that has happened since adding logging with log4Net.  When exceptions occur, they are caught and written as desired to the log.  However, running via both mstest and Visual Studio 2015, despite the fact exceptions occur, the tests are still seen as successful.

I verified it has something to do with the logging additions as I got the previous version from TFS and I'm able to run the tests in Visual Studio where the problematic tests do indicate failure.

I've attached a file that shows the steps I followed to get logging to work.  I'm not sure if the addition of an app.config file causes this to be handled differently within the testing framework or handling in Visual Studio.

Any help would be greatly appreciated!!

Selenium_and_Log4Net_Logging.docx


If you reply to this email, your message will be added to the discussion below:
http://apache-logging.6191.n7.nabble.com/Using-Log4Net-with-Selenium-tp59639p60848.html
To unsubscribe from Using Log4Net with Selenium, click here.
NAML




View this message in context: Re: Using Log4Net with Selenium
Sent from the Log4net - Users mailing list archive at Nabble.com.



If you reply to this email, your message will be added to the discussion below:
http://apache-logging.6191.n7.nabble.com/Using-Log4Net-with-Selenium-tp59639p60863.html
To unsubscribe from Using Log4Net with Selenium, click here.
NAML