【发布时间】:2012-03-20 15:38:10
【问题描述】:
我的任务是测试整个应用程序中多个弹出窗口的内容。所有弹出窗口都使用类似于以下内容的方式调用:
var win = new Window({ className: "spread", title: "Discussion",
left: 1, width: 410, height: 300, url: "Discussion.aspx?ID=" + id,
showEffectOptions: { duration: 0}})
由于我无法通过弹出窗口访问这些页面,因此我开始直接导航到这些页面。问题是页面被设计为在页面内的处理完成后关闭。 (window.close();)
在测试页面时,由于我直接访问该页面,因此我收到了The webpage you are viewing is trying to close the window. Do you want to close this window? 消息。
有没有办法使用 Watir(不是 Watir-webdriven)来访问消息并单击是或否?
PS - (如果重要,请使用 IE8。我试图找到禁用消息的方法,但无济于事)
更新 使用 IE Developer Tools,带有弹出框的通用 html 结构如下所示:
<html><body>
<iframe><form>... (Main page here)
<div class="dialog">
<div class="spread_close" onclick="Window.close()"/>
<table><tr><td><iframe> (table is not part of the "spread_close" div)
<html><body><form><div><table><tr><td>
<textarea name="txtDiscussion" id = "txtDiscussion" >
使用browser.div(:class => "spread_close").exists? 返回true。
使用browser.text_field(:name => "txtDiscussion").exists? 返回false。我认为这是因为双重<html>。
【问题讨论】:
-
我可以建议尝试通过弹出问题解决访问页面的问题吗?我发现这通常比尝试单击这些错误消息更容易。
-
你使用的是什么版本的 Watir?
-
Ruby 1.9.3 Watir 2.0.4 我之前曾尝试访问弹出窗口,并且在帮助下能够访问以关闭弹出窗口(感谢@ChuckvanderLinden),但即使在帮助下,无法成功访问弹出窗口内部的字段和按钮。 (“弹出窗口”可能不是最好的术语,但我对这种情况的了解是最好的)...link(链接到上一个关于关闭弹出窗口的问题)
标签: watir