我一直负责我们整个应用程序在测试的几个弹出框的内容。如何使用的Watir关闭“网页试图关闭此页”的消息
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,如果该事项我都试图找到方法来禁用该消息,但无济于事)
UPDATE 使用IE开发者工具,广义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>
。
可能我建议尝试通过弹出问题来解决访问页面吗?我发现通常比试图点击这些错误消息更容易。 – 2012-03-20 21:29:19
你在用什么版本的Watir? – 2012-03-21 07:45:55
的Ruby 1.9.3 的Watir 2.0.4 我曾尝试之前得到访问弹出式广告和与帮助,能得到访问能够关闭弹出窗口(感谢@ChuckvanderLinden),但即使有帮助,是无法成功访问**弹出窗口中的字段和按钮**。 (“Popup”可能不是最好的术语,但是我知道的最好的情况)... [link](http://stackoverflow.com/questions/8681869/trouble-attaching-to-a-javascript-window -with-watir)(链接到关于关闭弹出窗口的上一个问题) – swood 2012-03-21 13:16:01