I am currently trying to solve the same problem as you Corbellini.
I have different classes for each test case that I need and am currently logging the actions using java.util.logging.*
Here is my code for setting up the logger
<code>
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
public class DebugLogger {
public static Logger setUpLogger() {
Logger logger = Logger.getLogger("theTest.log");
Level debugLevel = Level.INFO;
// Level debugLevel = Level.FINE;
try {
FileHandler handler = new FileHandler("messagez.log", false);
logger.addHandler(handler);
logger.setLevel(debugLevel);
SimpleFormatter formatter = new SimpleFormatter();
handler.setFormatter(formatter);
} catch (IOException e){
System.out.println("Could not create file. Using the console handler");
}
return logger;
}
}
<code>
The problem with my approach is that I have to include a line of code before each action that I want to log for example
<code>
logger.info("Starting Test: Open Webpage");<code> This would be used when I start the test, I set the logging level as INFO so that it appears in my log no matter what
or for individual actions I use <code>logger.fine("Type 'aquarium' into search bar");<code>
I log the start and end of the test in the INFO level and use a line of code on logging level FINE for each action that I do and in my DebugLogger class I simply set the debugLevel to FINE(by commenting out INFO and de-commenting FINE). I set the debugLevel to fine if the test fails and I need to pinpoint where it failed(by looking at the generated log).
This method works, BUT it generates a single .log file that is just a large block of text, with alot of repeated timecode text.
For example:
24-Aug-2012 9:27:24 AM com.company.tests.OpenWebpage testOpenWebpage
INFO: Starting Test: Open Webpage in FireFox
24-Aug-2012 9:27:29 AM com.company.tests.OpenWebpage testOpenWebpage
INFO:Open Webpage has Passed in FireFox
24-Aug-2012 9:27:30 AM com.company.tests.OpenWebpage testOpenWebpage
INFO: Starting Test:
Open Webpage in Chrome
24-Aug-2012 9:27:35 AM com.company.tests.OpenWebpage testOpenWebpage
INFO:
Open Webpage has Passed in Chrome
Now imagine this repeated over and over for more than 15 test cases.
Also I think it would be worth mentioning that I am not using selenium grid due to the fact that I have searched high and low trying to figure out how to implement cross-browser testing in the grid to no avail. Instead my tests run sequentially in firefox then chrome using a driverFactory that I created.
All that being said, I am stuck in the same boat as you trying to figure out how to log these individual steps, and the pass/failure of a test case in a easy to read HTML file and am stuck. After reading all the comments I believe I am looking for the same kind of logging functionality that you desire and hope that we can find out a solution.
One thing I have noticed is that support for selenium on the web exists for many different implementations and often times I find it very hard to find solutions particular to my setup which is; Selenium Webdriver testing in Java using JUnit for testing. Most resources I find are solving Selenium RC issues, not webdriver.
If anyone can help us out that would be awesome!
Cheers