Reputation: 9
I'm stuck in one of the confirmation message. Below is the code.
boolean bFlag = selenium.isConfirmationPresent();
// which gives bFlag= false
selenium.chooseOkOnNextConfirmation();
selenium.click("//input[@value='Approve']");
// On clicking Approve button confirmation messasge is displayed.
boolean Flag = selenium.isConfirmationPresent();
// Which gives flag= true
Selenium is unable to click OK in the confirmation. I'm unable to continue with further coding. Nun of the selenium commands is working after clicking on approve button.
Can any one help me on this
Regards
Upvotes: 1
Views: 3121
Reputation: 3527
I only have a reference to a rather old piece of documentation, but I guess what is said there is still true http://release.seleniumhq.org/selenium-core/1.0.1/reference.html#chooseOkOnNextConfirmation
every time a confirmation comes up, you must consume it with a corresponding getConfirmation, or else the next selenium operation will fail.
So your code should look like this:
selenium.chooseOkOnNextConfirmation();
selenium.click("//input[@value='Approve']");
String confirmation = selenium.getConfirmation();
assertEquals("expected text of confirmation", confirmation); // check content of confirmation, optional
// now continue with more selenium commands
Upvotes: 1