0

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?

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I managed to disable Javascript for ChromeDriver 2.41.578706 like this: stackoverflow.com/a/57316009/1545579
-1
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();
    }

1 Comment

Hi and welcome! FYI: some explanations would significantly improve the quality of your answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.