使用 Selenium 处理浏览器弹出窗口 [英] Handling browser pop-up windows with Selenium

查看:31
本文介绍了使用 Selenium 处理浏览器弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在针对我们现有的代码库运行 Selenium 回归测试,并且我们的网络应用程序中的某些屏幕使用弹出窗口来执行中间步骤.

We are running Selenium regression tests against our existing code base, and certain screens in our web app use pop-ups for intermediate steps.

目前我们在测试中使用的命令:

Currently we use the commands in the test:

// force new window to open at this point - so we can select it later
selenium().getEval("this.browserbot.getCurrentWindow().open('', 'enquiryPopup')");
selenium().click("//input[@value='Submit']");
selenium().waitForPopUp("enquiryPopup", getWaitTime());
selenium().selectWindow("enquiryPopup");

...大部分时间都有效.有时测试会在 waitForPopUp() 行失败,并带有

...which works most of the time. Occasionally the test will fail on the waitForPopUp() line with

com.thoughtworks.selenium.SeleniumException: Permission denied

谁能推荐一个更好、更可靠的方法?

Can anyone suggest a better, more reliable method?

此外,我们主要在 IE6 和 7 上运行这些测试.

Also, we primarily run these tests on IE6 and 7.

推荐答案

成功了!!只是为了让喜欢 selenese 的人更容易.

It works!! Just to make it easier for the folks who prefer selenese.

这对我使用 IE7(正常模式)有效.

This worked for me using IE7(normal mode).

真是麻烦.感谢天空中的意大利面条怪物,否则我无法在 IE 中使用它.

What a freaking hassle. Thank the spaghetti monster in the sky for SO or there is no way I would have got this working in IE.

<tr>
    <td>getEval</td>
    <td>selenium.browserbot.getCurrentWindow().open('', 'windowName');</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>buttonName</td>
    <td></td>
</tr>
<tr>
    <td>windowFocus</td>
    <td>windowName</td>
    <td></td>
</tr>
<tr>
    <td>waitForPopUp</td>
    <td>windowName</td>
    <td>3000</td>
</tr>
<tr>
    <td>selectWindow</td>
    <td>windowName</td>
    <td></td>
</tr>

这篇关于使用 Selenium 处理浏览器弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆