title: Wait for a modal to disappear in Selenium 2.0
body: <p>When my test run using a webdriver for Firefox I'll get modal exception after reaching an accept on an alert:</p>
  
  <pre><code>[Exception]: Modal dialog present
  </code></pre>
  
  <p>The tests however work fine when using IE webdriver. The problem seems to be that test scenario proceeds before the alert is completely closed. In other words it tried to do the following:</p>
  
  <pre><code>List&lt;WebElement&gt; l = driver.findElements(By.linkText("link"));
  </code></pre>
  
  <p>and a result I'll get modal exception.</p>
  
  <p>Now <code>wait.until(ExpectedConditions)</code> as mentioned <a href="https://stackoverflow.com/q/14840884/2712086">wait.until(ExpectedConditions.visibilityOf Element1 OR Element2)</a> is good candidate. However I am not able to create a condition that returns true when alart disappears. How can I do that?</p>
  
  <p>Edit: to clarify further, the problem is not waiting for the alert to appear (my implicit wait is working fine for that purpose). I do get the alert and apply the test on that however after I click accept on the alert, test goes on fast and tried to proceed with the next step while alert still present and throws the modal present exception. I have also tried the following to prevent that with out success.</p>
  
  <pre><code>driver.switchTo().defaultContent();
  </code></pre>