title: handling "are you sure you want to navigate away from this page" Msg in Selenium 2.0
body: <p>Using Selenium 2.0
  After Submitting a web form, A popup msg comes up with the "are you sure you want to navigate away from this page" message, How do I get selenium to press OK or disable this popup?</p>
  
  <p>I have already tried </p>
  
  <pre><code>    Alert alert = driver.switchTo().alert();
      alert.accept(); 
  </code></pre>
  
  <p>or</p>
  
  <pre><code>    alert.dismiss();
  </code></pre>
  
  <p>edit:</p>
  
  <p>quick fix, I just overwrote the popup function using JS</p>
  
  <pre><code>    JavascriptExecutor js = (JavascriptExecutor) driver;
      js.executeScript("window.onbeforeunload = function() {};"); 
  
      form.submit();
  </code></pre>
  
  <p>this will stop will disable this popup, the same can be done for js alerts, comfirm and prompt boxes</p>