javascriptEnabled just works on HTMLUnitDriver.
And ChromeDriver should have JavaScript enabled to work properly in the first place, so you can´t disable JavaScript if you use ChromeDriver2.
Pregunta
https://code.google.com/p/selenium/issues/detail?id=3175 Doesn't work.
So then I tried this,
ChromeOptions opts = new ChromeOptions();
opts.addArguments("--disable-javascript");
driver = new ChromeDriver(opts);
But then driver.get(website); javascript is enabled again. When it was on data; it was disabled.
Also I tried,
DesiredCaptabilities caps = DesiredCaptabilties.chrome();
caps.setJAvaScriptEnabled(fale);
driver = new ChromeDriver(caps);
driver.get(Website);
Nothing is working. Any advice?
Solución
javascriptEnabled just works on HTMLUnitDriver.
And ChromeDriver should have JavaScript enabled to work properly in the first place, so you can´t disable JavaScript if you use ChromeDriver2.
Otros consejos
static public void DisableJS () {
driver.get("chrome://settings");
driver.switchTo().frame("settings");
driver.findElement(By.id("advanced-settings-expander")).click();
driver.findElement(By.id("privacyContentSettingsButton")).click();
//here do not allow js
driver.findElement(By.xpath("//*[@id='content-settings-page']/div[2]/section[3]/div/div[2]/label/input")).click();
driver.findElement(By.id("content-settings-overlay-confirm")).click();
}