【问题标题】:WatiN handling the IE 11 “Are you sure you want to leave this page?” popupWatiN 处理 IE 11 “您确定要离开此页面吗?”弹出窗口
【发布时间】:2017-02-09 21:34:34
【问题描述】:

我一直在尝试使用此代码

WatiN.Core.DialogHandlers.ReturnDialogHandler myHandler = new WatiN.Core.DialogHandlers.ReturnDialogHandler();
browser.AddDialogHandler(myHandler);

myHandler.WaitUntilExists();

myHandler.OKButton.Click();
browser.RemoveDialogHandler(myHandler);

用于处理网站在尝试将页面留在 onbeforeunload 处理程序。当尝试关闭浏览器时,Watin 会触发此事件。

上面的代码似乎不适用于ie11。 ie9 有一个特殊的处理程序,但 ie11 没有。

【问题讨论】:

    标签: c# watin


    【解决方案1】:

    我找到了一种关闭对话框的方法。我已经有一个全局变量来确定是否显示对话框,称为 link_was_clicked。通过像这样在 watin 代码中将其设置为 true

    browser.RunScript(@"link_was_clicked = true;");
    

    它实际上将其关闭。

    【讨论】:

      猜你喜欢
      • 2019-08-13
      • 1970-01-01
      • 2012-05-08
      • 1970-01-01
      • 2011-10-12
      • 1970-01-01
      • 1970-01-01
      • 2016-12-31
      • 1970-01-01
      相关资源
      最近更新 更多