title: selenium webdriver modal dialog java
body: <p>I am testing my form and when I don't type needed data I get javascript alert in my web app that tells the user to enter missing data. I can't handle this with selenium because when I partially fill form and try to submit I get exception </p>
  
  <pre><code>org.openqa.selenium.UnhandledAlertException: Modal dialog present
  </code></pre>
  
  <p>If I catch exception the alert in webdriver is not shown. Is that any solution to solve this issue?I would like to be able to submit form and catch the alert. I am using Linux Mint,Firefox 18 and selenium 2.28.0 with java
  Best regards
  UPDATE
  I have following in my code</p>
  
  <pre><code>somePage.fillName(sth); //only 1 of 2 required field are filled
  somgePage.submit(); //here js alert is shown right after clicking submit
  somePage.getCurrentAlert();
  //here are code parts
  public Alert getCurrentAlert(){
      return driver.switchTo().alert();
  }
  public AdminHome submit(){
          saveUrl();
          WebElement submit = driver.findElement(By.id("add_quiz_submit_button"));
          try{
              submit.click();
              if(urlChanged()){
                  return new AdminHome(driver);
              }
          }
          catch(Exception e){
              e.printStackTrace();// exception 1
              return null;
          }
          return null;
      }
  //Exception 1
  org.openqa.selenium.UnhandledAlertException: Modal dialog present
  //The test fails because of:
  org.openqa.selenium.NoAlertPresentException: No alert is present (WARNING: The server did not provide any stacktrace information)
  </code></pre>
  
  <p>However if I click manual on submit the test work as expected. Thanks in advance</p>