I'm using Selenium 2.20 with Firefox 10.
When i execute JavaScript code:
try {
((JavascriptExecutor) webDriver.executeScript(script, args);
} catch(Exception e) {
System.err.println(e.getMessage());
}
and the code contains or produces a JavaScript exception, i am not able to retrieve the error message. Instead it returns null most of the time.
I also tried this JS code:
// error handling
window.onerror = function(msg, url, linenumber) {
var error = document.createAttribute("javaScriptErrorMessage");
error.nodeValue = msg + "\n at line number " + linenumber + " (URL: " + url + ")";
document.getElementsByTagName("body")[0].setAttributeNode(error);
};
But that doesn't seem to work either. When i try to get the error attribute in the body tag, it also equals null.
This is the Exception i get in Java:
org.openqa.selenium.WebDriverException: null (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 8 milliseconds
Build info: version: '2.20.0', revision: '16008', time: '2012-02-28 15:00:40'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.35-32-generic', java.version: '1.6.0_20'
Driver info: driver.version: RemoteWebDriver
The relevant part seems to be the message WARNING: The server did not provide any stacktrace information. But i have no clue why this happens. Maybe a Firefox setting which needs to be changed?
Do i use the JavascriptExecutor wrongly?