title: Possible to dismiss JS alerts automatically whenever an unhandled one appears?
body: <p>The issue I'm running into is that sometimes JS dialogue behavior is unpredictable within the application being tested. I wish I could say I could do anything about it, but I can't because I am only experiencing this weird behavior with cucumber. Also, it's not of my concern to test the actual dialogue boxes. In other words, we just want to click through and dismiss them whenever they happen.</p>
  
  <pre><code>begin
      find('div', :text =&gt; 'Cancel').double_click # Click cancel
      accept_browser_dialog # We've got two dialogue boxes to click through
      accept_browser_dialog # That makes two.. but what if a third was created?
      # Wouldn't it be great if I could just dismiss them as they appeared?
  rescue Selenium::WebDriver::Error::UnhandledAlertError # &lt;- SOMETHING LIKE THIS
      accept_browser_dialog # Handled easy as pie.. in theory
  end # etc etc etc
  </code></pre>
  
  <p>See the line I marked above. Every time I click 'Cancel' there are two dialogues to click through, but sometimes the <code>double_click</code> call likes to bring up a third dialogue box. Rather than playing games with counting dialogues and the like, is there any way to simply dismiss them as they appear whenever an unhandled alert error happens?</p>