带对话框的硒测试问题
我想使用 selenium 来测试我的网络应用程序。
它有效......但是......
对于确认对话框,我重写了
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{
}
}
});
}
我使用jquery的方法和用于确认框图形的插件Impromptu。
我用 Selenium IDE 记录我的测试。 当我开始测试并且测试失败后。 测试是“单击链接,应该出现对话框(即兴样式),然后我想按“确定”键”
测试代码
<!-- 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 > div:nth(2) > p > 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 > table > tbody > tr:nth(1) > td:nth(1) > table.entrata > tbody > tr > td > a > 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>
这是由 < 生成的 强>Selenium IDE。
问题是什么?
请帮助我,
问候,
托马索
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 > div:nth(2) > p > 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 > table > tbody > tr:nth(1) > td:nth(1) > table.entrata > tbody > tr > td > a > 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这很可能是一个时间问题。您需要让 selenium 在
assertConfirmation
之前等待对话框出现。另外,我怀疑该调用实际上仅适用于真正的 JS 弹出窗口,而不是真正模态的 jQuery 风格“假”弹出窗口,因此您应该使用普通的断言。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.