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

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

问题描述

我们正在针对现有代码库运行Selenium回归测试,我们的Web应用程序中的某些屏幕使用弹出窗口进行中间步骤。

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

任何人都可以建议更好,更可靠 / em>方法?

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天全站免登陆