如何使用 Watir 关闭"Webpage trying to close this page"消息



我的任务是测试整个应用程序中几个弹出窗口的内容。所有的弹出窗口都使用类似的东西调用:

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网络驱动)访问消息并单击"是"或"否"的方法?

PS-(使用IE8,如果这很重要的话。我试图找到禁用消息的方法,但没有用)

更新使用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" >

使用CCD_ 3返回CCD_。

使用CCD_ 5返回CCD_。我想这是因为双重<html>

您有框架。这很可能是阻止访问的原因,很可能这些实际上不是一个弹出窗口,而是一个"lightbox"div,它使用样式等看起来像是一个弹出或模式对话框。

在watir wiki上查找关于如何处理框架的内容,你就应该上路了。

最新更新