I am having a code like the following
selenium.chooseCancelOnNextConfirmation();
selenium.click(“deleteRequest”);// confirm dialog will be displayed on clicking the button
System.out.println(“is confirmation present “+selenium.isConfirmationPresent());
Eventhough i am using selenium.chooseCancelOnNextConfirmation(), please let me know why selenium.isConfirmationPresent() returns true.
But selenium.isConfirmationPresent() returns false after
selenium.getConfirmation();
Is it mandatory to use selenium.getConfirmation(), as i am not able to do further processing. It says
com.thoughtworks.selenium.SeleniumException: ERROR: There was an unexpected Confirmation! [Are you sure to delete selected request(s)?]
com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:9
This is the expected behaviour. chooseCancelOnNextConfirmation() dictates the behaviour of getConfirmation(). Calling getConfirmation() effectively “consumes” the confirmation popup. You must use getConfirmation or verifyConfirmation before continuing your test, as any other Selenium command will fail if you do not handle the popup with a getConfirmation call.
So your code could be: