Take the 2-minute tour ×

I need to disable default alt+c behavior of IE 9. I am executing the java script code in Junit framework which is using Selenium Webdriver for browser launch. I am using following code

JavascriptExecutor js = (JavascriptExecutor) driver;
        js.executeScript("document.addEventListener(\"keydown\", function(oEvent) {if (oEvent.keyCode == 18 && oEvent.altKey) oEvent.preventDefault();}, false)");

But getting following error

org.openqa.selenium.WebDriverException: JavaScript error (WARNING: The server did not provide any stacktrace information)

I don't have much knowledge of JavaScript so not able to debug why I am getting this error. Can anyone Please provide me appropriate solution.

Here I want to add one more thing this code is not giving any error in FF12, but not disabling the default property of ALT key in FF12. eg I want to disable alt+h property of FF12 but after execution of this JS code when I am clicking alt+h key its still opening Help.

@user4815162342 I am getting following error

Command duration or timeout: 13 milliseconds
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:08:56'
Driver info: driver.version: RemoteWebDriver
Session ID: 35c59739-1ee4-4231-9d43-ce8f20d2a9bf
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:498)
    at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:407)
share|improve this question
I'd go into IE's error console to see what error it's giving. –  user4815162342 Dec 17 '12 at 5:51
That looks like some sort of Java stacktrace. Is that what IE is reporting, or what selenium is reporting? (I'm not completely familiar with selenium, which is why I'd find something more useful in IE). –  user4815162342 Dec 17 '12 at 7:02
Have you tried just loading that code in a script in a web page and seeing if that worked? In other words, get rid of the selenium layer, and debug it from there. If it works there, but not with selenium involved, then it's a selenium issue, and you might have good luck asking on their support forums. –  user4815162342 Dec 17 '12 at 7:07
Please can you please let me know how to load the in the webPage without using slenium. –  Arun Dec 17 '12 at 9:44
Add a script tag to the web page. –  user4815162342 Dec 17 '12 at 14:03
add comment

Your Answer



Browse other questions tagged or ask your own question.