开发者

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>clic开发者_如何学JAVAkAndWait</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?


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.


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>


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


In Selenium IDE you can use waitForConfirmation(pattern)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜