title: How to use close alert and get text
body: <p>Every Java code export from selenium ide will have this method..But it is the same with method for iselementpresent because I cant figured out how to use it:</p>
  
  <pre><code>private String closeAlertAndGetItsText() {
      try {
        Alert alert = driver.switchTo().alert();
        if (acceptNextAlert) {
          alert.accept();
        } else {
          alert.dismiss();
        }
        return alert.getText();
      } finally {
        acceptNextAlert = true;
      }
    }
  </code></pre>
  
  <p>What need to be put exactly in the try code?</p>