I have written a code to find if any alert there if so click on alert and continue else continue the flow using below code:
fd.findElement(By.name("submit")).click();
String str="";
Alert alert =null;
try{
alert = fd.switchTo().alert();
if(alert!=null && !"".equals(alert)){
str= alert.getText();
System.out.println("alert there");
}
}catch(NoAlertPresentException e){
e.printStackTrace();
str = "";
System.out.println("no alert");
}
System.out.println("print alert::::--->:"+alert);
System.out.println("print alert:str--->"+str);
my flow is working but in console am getting an error stating:
No alert is present (WARNING: The server did not provide any stacktrace information)
How do I resolve this issue?