title: When I show a dialog, an exception "UnhandledAlertException: Modal dialog present" is thrown
body: <p>I am using internet explorer 9 to login a website using Selenium Webdriver 2.42.2.</p>
  
  <p>When I enter the credentials and press the login button, a modal dialog box pops up saying :</p>
  
  <blockquote>
    <p>You are already logged on to the same physical device. Do you wish
    logout from the previous login &amp; login again?</p>
  </blockquote>
  
  <p>So there are 2 options Yes / No.</p>
  
  <p>I have used the <code>driver.switchTo().alert.accept()</code> but the alert just disappears quickly after appearing, in fraction of a second. It does not click on the Yes button, as it should.</p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>public class launch{
      public static void main(Sting args[]){
          driver.findElement(By.id("login")).click();// click performed
  
          launch obj = new launch();
          if(obj.isAlertPresent(driver) == true)
          {
              Thread.sleep(3000);
              driver.switchTo().alert();
              String a = driver.getTitle();
              System.out.println(a);
          }
      }
      public boolean isAlertPresent(WebDriver drive) throws InterruptedException 
      { 
          try 
          { 
              Thread.sleep(2000);
              drive.switchTo().alert(); 
              Thread.sleep(2000);
              return true; 
          }   
          catch (UnhandledAlertException Ex) 
          { 
              return false; 
          }
      }
  }
  </code></pre>
  
  <p><strong>Log:</strong></p>
  
  <pre><code>Started InternetExplorerDriver server (64-bit)
  2.42.0.0
  Listening on port 5600
  Exception in thread "main" org.openqa.selenium.UnhandledAlertException: Modal dialog present: You are already logged on to the same physical device. Do you wish logout from the previous login &amp; login again ?
  
  Driver info: org.openqa.selenium.ie.InternetExplorerDriver
  Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=9, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, , takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
  Session ID: e439a04d-98aa-45e3-ae87-ec30e6f2cd2a
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
      at org.openqa.selenium.remote.ErrorHandler.createUnhandledAlertException(ErrorHandler.java:185)
      at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:152)
      at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
      at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:614)
      at org.openqa.selenium.remote.RemoteWebDriver.getWindowHandle(RemoteWebDriver.java:489)
      at OneWebTest.webrio_launch.main(webrio_launch.java:29)
  </code></pre>