I am currently working with Selenium 2.20 in conjunction with Firefox 10.
When I run the JavaScript code:
try {
((JavascriptExecutor) webDriver.executeScript(script, args);
} catch(Exception e) {
System.err.println(e.getMessage());
}
If the code contains a JavaScript exception, I am unable to retrieve the error message and it often returns null.
I attempted another approach with 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);
};
However, attempting to access the error attribute in the body tag also results in a null value.
The Java Exception that is thrown is as follows:
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 most pertinent part appears to be the message
WARNING: The server did not provide any stacktrace information
. However, it remains unclear why this issue is occurring. Could it possibly be related to a setting in Firefox that requires adjustment?
Am I utilizing the JavascriptExecutor incorrectly?