title: How to disable JavaScript in browser using Selenium (Java)?
body: <p>In my feature automation, I need to disable JavaScript in browser and run the flow. How to disable JavaScript? </p>
  
  <p>Tried DesiredCapabilities for firefox and Chrome. </p>
  
  <pre><code>DesiredCapabilities dc = new DesiredCapabilities();
  dc.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT, false)
  </code></pre>
  
  <p>And</p>
  
  <pre><code>DesiredCapabilities dc = new DesiredCapabilities();
  dc.setJavascriptEnabled(false);
  </code></pre>
  
  <p>For firefox, tried 
  1) Setting up profile for firefox</p>
  
  <p>2) Adding add-on - noScript.xpi </p>
  
  <p>3) profile.setPreference("javascript.enabled", false);</p>
  
  <p>4) Through UI, tried changing the flag - "javascript.enabled" in "about:config" to false. Here, opened firefox and gave "about:config" getting a warning - "This might void your warranty!". There is a button - "I'll be careful, I promise!" with id - warningButton. This button should be clicked to proceed further. To click this button, used driver.findElement(By.id("warningButton")).click(); but it not work.</p>
  
  <p>All the above options are not working. Any advice will be helpful.</p>