使用Selenium处理浏览器弹出窗口
我们正在针对现有代码库运行Selenium回归测试,并且我们的Web应用程序中的某些屏幕使用中间步骤的弹出窗口。使用Selenium处理浏览器弹出窗口
目前我们使用的测试命令:
// 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()
线失败,并
com.thoughtworks.selenium.SeleniumException: Permission denied
任何人都可以提出一个更好,更可靠方法?
此外,我们主要是如果您在* iehta模式下运行,那么你要在这里和那里遇到了一些小问题上运行IE6和这些测试7.
它的作品!只是为了让喜欢selenese的人们更容易。
这对我来说使用IE7(普通模式)。
什么是一个惊人的麻烦。感谢天空中的意大利面怪兽,或者我不可能在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,而IE和AJAX似乎存在很多问题。
但是,这听起来像是您遇到的问题是Selenium在完全加载之前尝试访问另一个窗口中的组件的问题。我不确定默认的超时范围设置为什么,但您可能想尝试将其增加到60(60000毫秒)左右以解决问题。
除此之外,我建议在Firefox中运行测试(使用* chrome),因为它会产生更可靠的结果,但有时由于业务需求而无法实现。
哦,相信我,我希望我们可以在Firefox中运行它!但我们99%的用户使用IE,所以这是测试的优先考虑... 我们使用* iexplore,而不是* iehta。我不知道有什么不同? – brasskazoo 2008-09-19 03:18:24
* iehta和* chrome允许https支持。这样您就不必担心证书带来的问题。 – Josh 2008-09-19 03:48:10
我只是试用,增加另一个硒功能,windowFocus()
:
// 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().windowFocus("enquiryPopup");
selenium().waitForPopUp("enquiryPopup", getWaitTime());
selenium().selectWindow("enquiryPopup");
,当我跑在本地测试成功,但只有与所有这些方法调用 - 创建/聚焦/等待/选择。
我正准备让构建服务器运行所有测试,如果成功,我将使用它的库函数......!
请让我们知道它是否工作! – mcherm 2008-09-22 20:34:22
尝试在导致问题的调用中添加一些等待语句。
我有同样的错误,我能够前的唯一途径可靠解决这些问题是通过向System.Threading.Thread.Sleep电话(5000)..
我需要在弹出窗口中选择一个iframe并填写表单。 我在selenium无法找到我的iframe时使用selectWindow cmd时遇到了问题,所以我删除了该命令。
这Selenese的工作很适合我(其中的iframe标题和id = account_frame):
<tr>
<td>click</td>
<td>//a[@class='item_add']</td>
<td></td>
</tr>
<tr>
<td>windowFocus</td>
<td>account_frame</td>
<td></td>
</tr>
<tr>
<td>waitForPopUp</td>
<td>account_frame</td>
<td>10000</td>
</tr>
什么是地狱与此线程是什么呢?下面有5个不同的人试图劫持它! – ryeguy 2009-10-22 21:26:39