public boolean consume_Confirmation_Alert() throws Exception {
    boolean presentFlag = false;
    try{
        Alert alert = driver.switchTo().alert(); //Check the presence of alert
        presentFlag = true; //Alert present; set the flag
        alert.accept(); //if present consume the alert
    }catch (NoAlertPresentException ex){
        ex.printStackTrace(); //Alert not present
    }
    return presentFlag;
}
share me!:))Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone
Print this page