title: How to fix "unexpected alert open: {Alert text : } " error
body: <p>I have a project in ruby with AngularJS and I'm currently converting tests over to Headless chrome from Phantomjs, and I keep getting an error:</p>
  
  <pre><code>Selenium::WebDriver::Error::UnhandledAlertError:
              unexpected alert open: {Alert text : }
  </code></pre>
  
  <p>This happens throughout multiple test files..
  I have tried adding </p>
  
  <p>"accept_alert {} " before a command :</p>
  
  <pre><code>#from
  
  find('.sp-advanced-configuration').click
  
  #to
  accept_alert{ find('.sp-advanced-configuration').click  } 
  
  </code></pre>
  
  <p>but receive </p>
  
  <pre><code>Failure/Error: accept_alert{ ... }
  
            Capybara::ModalNotFound:
              Unable to find modal dialog
  
  </code></pre>
  
  <p>as well as</p>
  
  <pre><code>Selenium::WebDriver::Error::UnhandledAlertError:
              unexpected alert open: {Alert text : }
  </code></pre>
  
  <p>Not sure what else to try</p>
  
  <p>/*********** *********/</p>
  
  <p>After looking into this further, It seems the issue occurs whenever there are unsaved changes left on the test before moving onto the next test. </p>
  
  <p>Is there a way where you can accept this for every test without having to add </p>
  
  <pre><code> after do 
      execute_script('window.onbeforeunload = undefined')
    end
  </code></pre>
  
  <p>in every test file?</p>