Recommended usage
@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
}
}
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.
Additionally be aware that there are two places where screenshots are taken.
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();