Hi,selenium version: 2.25.0
browser used: firefox
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_31'
Driver info: driver.version: RemoteWebDriver
Problem:------------While running a selenium test script, I am not able to handle the "Modal dialog box" .i.e. when I click on a button, it pops up the Modal dialog box with OK, Cancel buttons. When I click on Ok button, it takes me into another page.But when I run my script, it just gives me below error:org.openqa.selenium.UnhandledAlertException : Modal dialog presentAlso, on the screen I get the pop up window with this message :An AJAX HTTP request terminated abnormally.Debugging information follows,Path: /system/ajaxStatus Text: errorResponse Text:ReadySate: 0The sample code that I have used in my code is:----------------------------------------------------------------WebElement button = driver.findElement(By.id("confirm"));
button.click();
try {
//Get the Alert
Alert alert = driver.switchTo().alert();
alert.accept();
}
catch (NoAlertPresentException e) {
e.printStackTrace();
}
Regards,
Anita
button.click();
try {
//Get the Alert
Alert alert = driver.switchTo().alert();
org.openqa.selenium.UnhandledAlertException : Modal dialog present
I guess ur codes need sleep for a while before handle alert, I guess switchTo().alert() were executed before the real alert dialog popup.
I am currently getting the same error when I try to handle a modal popup. I tried a try-catch statement to handle the exception but it never seems to hit it (the code inside of the catch is never executed)
I guess your webdriver were hang when you click button to open the modal dialog, webdriver will hang when showModalDialog method be invoked. There is another session which has the solution, you can have a look.
--david
I used the following statement:
driver.switchTo().alert().accept();
I found this statement on http://grokbase.com/t/gg/webdriver/127kzrvxqn/click-on-pop-up-windows
Manoj knew the secret.