I suggest not dynamically disabling javascript, since most webdriver functions are written in javascript, and therefore it can sometimes give unexpected results. It's better to use Firefox Profiles to disable it, but I wrote code that can help you disable it at runtime.
WebDriver driver = new FirefoxDriver(); driver.get("about:config"); Actions act = new Actions(driver); act.sendKeys(Keys.RETURN).sendKeys("javascript.enabled").perform(); Thread.sleep(1000); act.sendKeys(Keys.TAB).sendKeys(Keys.RETURN).sendKeys(Keys.F5).perform();
If you are using the Selenium IDE, you can link to http://thom.org.uk/2006/03/12/disabling-javascript-from-selenium/ .
source share