I am using a Chrome Driver and trying to test a webpage.
Normally it runs fine, but sometimes I get exceptions:
org.openqa.selenium.UnhandledAlertE
After click event add this below code to handle
try{
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
catch (org.openqa.selenium.UnhandledAlertException e) {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText().trim();
System.out.println("Alert data: "+ alertText);
alert.dismiss();}
... do other things driver.close();