1
votes

I wanna use selenium for testing my web app.

It works ... but ...

For the confirm dialog box I've rewrite the method

function confirm(text,cbk) {
                                $.prompt(text,{
                                    buttons:{Ok:true, Cancel:false},
                                    opacity: 0.3,
                                    overlayspeed: 'fast',
                                    promptspeed: 'slow',
                                    callback: function(v,m){
                                        if(v){
                                            cbk.call();
                                        }
                                        else{

                                        }
                                    }
                                });
                            }

I was used jquery and the plugin Impromptu for the graphic of the confirm box.

I record my test with Selenium IDE. After I start my test and the test fail. The test is "click in a link and should be appear the dialog box (impromptu style), and after that I wanna press key 'Ok'"

This is the code of the test

<!-- login page -->
<tr>
    <td>open</td>
    <td>/demoit/action/Home</td>
    <td></td>
</tr>
<!-- inser the username and the password -->
<tr>
    <td>type</td>
    <td>user_name</td>
    <td>tommaso</td>
</tr>
<tr>
    <td>type</td>
    <td>pass_word</td>
    <td>pwdtommaso</td>
</tr>
<!-- click in the login image that call a script for login -->
<tr>
    <td>clickAndWait</td>
    <td>css=body &gt; div:nth(2) &gt; p &gt; img</td>
    <td></td>
</tr>
<tr>
    <td>chooseCancelOnNextConfirmation</td>
    <td></td>
    <td></td>
</tr>
<!-- click on exit link -->
<tr>
    <td>click</td>
    <td>css=#mycontentheader &gt; table &gt; tbody &gt; tr:nth(1) &gt; td:nth(1) &gt; table.entrata &gt; tbody &gt; tr &gt; td &gt; a &gt; img</td>
    <td></td>
</tr>
<tr>
    <td>assertConfirmation</td>
    <td>Do you want to exit?</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>jqi_state0_buttonOk</td>
    <td></td>
</tr>

That was produced by Selenium IDE.

What is the problem?

Please help me,

Regards,

Tommaso

1
Please show us the relevant selenium test code. - cweiske

1 Answers

2
votes

It's likely to be a timing issue. You need to make selenium wait for the dialog box to appear before the assertConfirmation. Also I suspect that call is really only for genuine JS popups rather than jQuery style 'fake' popups that aren't really modal, so you should probably use a normal assert.