title: org.openqa.selenium.UnhandledAlertException: unexpected alert open
body: <p>I am using a Chrome Driver and trying to test a webpage. </p>
  
  <p>Normally it runs fine, but sometimes I get exceptions:</p>
  
  <pre><code> org.openqa.selenium.UnhandledAlertException: unexpected alert open
   (Session info: chrome=38.0.2125.111)
   (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 x86) (WARNING: The server did not  provide any stacktrace information)
   Command duration or timeout: 16 milliseconds: null
   Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:30'
   System info: host: 'Casper-PC', ip: '10.0.0.4', os.name: 'Windows 7', os.arch: 'x86', os.version:  '6.1', java.version: '1.8.0_25'
   Driver info: org.openqa.selenium.chrome.ChromeDriver
  </code></pre>
  
  <p>Then I tried to handle the alert:</p>
  
  <pre><code>  Alert alt = driver.switchTo().alert();
    alt.accept();
  </code></pre>
  
  <p>But this time I received:</p>
  
  <pre><code>org.openqa.selenium.NoAlertPresentException 
  </code></pre>
  
  <p>I am attaching the screenshots of the alert:
  <img src="https://i.stack.imgur.com/lumAs.jpg" alt="First Alert and by using esc or enter i gets the second alert"><img src="https://i.stack.imgur.com/8oefT.jpg" alt="Second Alert"></p>
  
  <p>I am not able to figure out what to do now. The problem is that I do not always receive this exception. And when it occurs, the test fails.</p>