It seems to be a not very common task but very interesting one. I do not think that there's some standard way so something has to be implemented.
I do not know Perl much and I use Java, so this is just a heads up:
I would extend the DefaultSelenium
class for my tests that will use extended HttpCommandProcessor
that will logs all commands performed:
import com.thoughtworks.selenium.HttpCommandProcessor;
public class ExtHttpCommandProcessor extends HttpCommandProcessor {
public ExtHttpCommandProcessor(String serverHost, int serverPort,
String browserStartCommand, String browserURL) {
super(serverHost, serverPort, browserStartCommand, browserURL);
}
public String doCommand(String commandName, String[] args) {
StringBuffer sb = new StringBuffer();
sb.append("|" + commandName + "|");
if (args!=null) {
for (String arg : args) {
sb.append(arg + "|");
}
if (args.length<2) {
sb.append(" |");
}
} else {
sb.append(" | |");
}
System.out.println(sb.toString());
// or log it where you want
return super.doCommand(commandName, args);
}
}
And
import com.thoughtworks.selenium.DefaultSelenium;
public class ExtSelenium extends DefaultSelenium {
public ExtSelenium(String serverHost, int serverPort,
String browserStartCommand, String browserURL) {
super(new ExtHttpCommandProcessor(serverHost, serverPort, browserStartCommand, browserURL));
}
}
Then I would extend SeleneseTestCase
for use as the base in my tests:
import com.thoughtworks.selenium.SeleneseTestCase;
public class ExSeleneseTestCase extends SeleneseTestCase {
public void setUp(String url, String browserString) throws Exception {
int port = 4444;
if (url==null) {
url = "http://localhost:" + port;
}
selenium = new ExtSelenium("localhost", port, browserString, url);
selenium.start();
selenium.setContext(this.getClass().getSimpleName() + "." + getName());
}
}
The output of such test will look like:
|getNewBrowserSession|*iexplore|http://localhost:8080/|
|setContext|SimpleTest.testNew| |
|open|/webapp/test.html| |
|isTextPresent|Sample text| |
|click|sampleLink| |
|waitForPageToLoad|10000| |
|testComplete| | |
This solution will not log verify
s and assert
s so they may also be overrided in ExSeleneseTestCase to produce some trace.