Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium IDE - There was an unexpected Confirmation!

I have a button that displays Javascript confirmation popup. This is a part of my test case:

<tr>
    <td>clickAndWait</td>
    <td>buttonId</td>
    <td></td>
</tr>
<tr>
    <td>verifyTextPresent</td>
    <td>Object has been deleted</td>
    <td></td>
</tr>

It works as expected: OK is clicked automatically on a popup and verifyTextPresent return true. Still, I get [error] There was an unexpected Confirmation! in the log and test case fails.

Any suggestions?

like image 771
Ula Krukar Avatar asked Jan 14 '10 08:01

Ula Krukar


3 Answers

Summary: In the IDE use storeConfirmation.

You have to consume confirmation dialogs. Otherwise the Selenium test will fail.

From the Java Selenium RC API Selenium.html.getConfirmation method:

If a confirmation is generated but you do not consume it with getConfirmation method, the next Selenium action will fail.

Edit:

storeConfirmation consumes the confirmation as well.

storeConfirmation ( variableName )

Retrieves the message of a JavaScript confirmation dialog generated during the previous action.

If a confirmation is generated but you do not consume it with getConfirmation method, the next Selenium action will fail.

like image 181
Thomas Jung Avatar answered Oct 13 '22 18:10

Thomas Jung


I encountered the same problem, and I solved it like this:

chooseOkOnNextConfirmation click buttonId assertConfirmation

This makes my test run green in my Selenium IDE.

The code to do this is:

<tr>
    <td>chooseOkOnNextConfirmation</td>
    <td></td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>ctl00_CPHMain_ucFormDMS_grdDocumentList_ctl00_ctl04_btnDelete</td>
    <td></td>
</tr>
<tr>
    <td>assertConfirmation</td>
    <td>Areyousureyouwanttodeletethisdocument?</td>
    <td></td>
</tr>
like image 39
Knubo Avatar answered Oct 13 '22 18:10

Knubo


using selenium.chooseOkOnNextConfirmation is correct but insead of using this alone use

selenium.click("xpath=//button"); selenium.getConfirmation(); selenium.chooseOkOnNextConfirmation(); Here it will first click on the button and get the confirmation , then it would click OK from that confirmation

like image 1
Peeyush Kapoor Avatar answered Oct 13 '22 19:10

Peeyush Kapoor