Q:

How to disable Javascript when using Selenium by JAVA?

I'm using selenium for web test by JAVA.
I want to stop JavaScript on Firefox Browser,Google Chrome Browser,IE Browser.
I tried this code on Firefox Browser.
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("javascript.enabled", false);
WebDriver driver = new FirefoxDriver(profile);

But it's return this error on second line.
Exception in thread "main" java.lang.IllegalArgumentException: Preference javascript.enabled may not be overridden: frozen value=true, requested value=false

How to disable Javascript when using Selenium each Browser?
If you know about this problem,Please help me!

A:

Use noscript addon for firefox. Right click on the Add to Firefox button and Save link as that will give you the option to save the .xpi. Then, configure the the Firefox profiler as follows.
FirefoxProfile profile = new FirefoxProfile();
profile.AddExtension(@"PATH\TO\noScript.xpi");
IWebDriver driver = new FirefoxDriver(profile);

driver.Navigate().GoToUrl("http://localhost:8080/");

