Find Alert is present or not

 public boolean isAlertPresent() //user defined method created to check alert is present or not

{

try

{

driver.switchTo().alert();

return true;

}

catch(NoAlertPresentException e)

{

return false;

}

}