Examples

sample successful report

Here is an sample successful report and the corresponding source .

sample Junit assertion failed report

Here is an sample Junit assertion failed report and the corresponding source .

sample Wait Timed Out report

Here is an sample Wait Timed Out report and the corresponding source .

sample Notify Callback report

Here are sample with notifier callback(1) report and sample with notifier callback(2) report and the corresponding source .

Basic Usage

Recommended usage

  • This library provides extensible logging feature to selenium-remote-control
  • Currently there is a HtmlResultFormatter implemented which outputs HTML
  • This extension assumes selenium tests are driven by Junit 4. No other selenium usage has been tested with this extension
  • Use this extension as follows
    @Before
    public void setUp() {
        final String resultPath = "absolute-path-to-where-your-result-will-be-written";
        final String resultHtmlFileName = resultPath + File.separator + "result.html";
        final String resultEncoding = "UTF-8"
        loggingWriter = LoggingUtils.createWriter(resultHtmlFileName, resultEncoding);
    
        LoggingResultsFormatter htmlFormatter = 
            new HtmlResultFormatter(loggingWriter, resultEncoding);
        htmlFormatter.setScreenShotBaseUri(""); // this is for linking to the screenshots
        htmlFormatter.setAutomaticScreenshotPath(resultPath);
        // wrap HttpCommandProcessor from remote-control
        LoggingCommandProcessor myProcessor = 
            new LoggingCommandProcessor(new HttpCommandProcessor(your-configs), htmlFormatter);
        selenium = new LoggingDefaultSelenium(myProcessor);
        selenium.start();
    }
    
    @After
    public void tearDown() {
        selenium.stop();
        try {
            if (null != loggingWriter) {
                loggingWriter.close();
            }
        } catch (IOException e) {
            // do nothing
        }
    }
              

Screenshot Gotchas

How to configure correct linking and file storage.

Two kinds of paths have to be differentiated to get LoggingSelenium storing the screenshots in the right place and link them correct from within the result.

  • storage: filesystem paths are separated through OS-dependant chars (e.g. "/" for unix, "\" for windows)
  • linking: urls use "/" to separate paths

Additionally be aware that there are two places where screenshots are taken.

  • user-defined: whenever you decide to call captureScreenshot
  • automatic: LoggingSelenium will take an automatic screenshot if an execption is thrown (e.g. junit assertion, wait timeout)

Directories must exist. LoggingSelenium will not create them.

It is recommended to use absolute filesystem paths to ensure always correct storage. Example:

private String resultsPath = new File("results").getAbsolutePath();