I'm trying to click on a pop-up alert message on a UI with Selenium Webdriver.
The problem is, it is not clicking on accept or cancel even if I explicitly and implicitly wait. Is there any other alternative to clicking on a pop-up message. I tried to send key by Robot and press enter, but it did not work too.
click ok popup message function:
try {
WebDriverWait wait = new WebDriverWait(driver, 40);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
report.log(LogStatus.INFO, "Displayed Pop-up Window Alert Message -> " + alert.getText() + " for the Field -> " + fieldName);
System.out.println("Displayed Pop-up Window Alert Message -> " + alert.getText() + " for the Field -> " + fieldName);
alert.accept();
Thread.sleep(3000);
} catch (NoAlertPresentException ex) {
System.err.println("Error came while waiting for the alert popup. ");
report.log(LogStatus.INFO, "Alert pop up box is NOT populating when user clicks on: ");
}
this is what the html looks like for the popup:
<input type="submit" name="ctl00$ctl00$Content$ContentPlaceHolderMain$Continue" value="Continue..."
onclick="if(warnOnDelete('ctl00_ctl00_Content_ContentPlaceHolderMain_EditRadioOptions_1',"
+ "'Please confirm if you wish to delete.') == false) return false;"
id="ctl00_ctl00_Content_ContentPlaceHolderMain_Continue" style="width:100px;">
It has to be in IE, we are not allow to use anything except IE
Update: function for the confirm boxes
function warnOnDelete(deleteButtonID, msg) {
var deleteRadioButton = document.getElementById(deleteButtonID);
if (deleteRadioButton != null) {
if (deleteRadioButton.checked == true)
return confirm(msg);
}
return true;
}