如何在Internet Explorer弹出窗口下方处理“确定要离开此页面?"通过硒 [英] How to handle below Internet Explorer popup "Are you sure you want to leave this page?" through Selenium

查看:583
本文介绍了如何在Internet Explorer弹出窗口下方处理“确定要离开此页面?"通过硒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何处理Selenium中的IE弹出窗口以下

How to Handle below IE Popup in Selenium

推荐答案

Internet Explorer 弹出窗口,其文本为确定要离开此页面吗? WindowEventHandlers.onbeforeunload

The Internet Explorer popup with text as Are you sure you want to leave this page? is the result of WindowEventHandlers.onbeforeunload

onbeforeunload 属性href ="https://developer.mozilla.org/zh-CN/docs/Web/API/WindowEventHandlers" rel ="nofollow noreferrer"> WindowEventHandlers mixin是卸载其资源时,会触发这些事件.此时,文档仍然可见,事件仍可取消.

The onbeforeunload property of the WindowEventHandlers mixin is the EventHandler for processing beforeunload events. These events fire when a window is about to unload its resources. At this point, the document is still visible and the event is still cancelable.

有多种策略可用于处理此弹出窗口.但是,作为跨浏览器解决方案,您可以禁用此对话框,调用executeScript()window.onbeforeunload设置为 function() {}; ,并且可以使用以下解决方案:

There are different strategies available to handle this popup. However, as a Cross Browser solution, you can disable this dialog invoking the executeScript() to set window.onbeforeunload as function() {}; and you can use the following solution:

((JavascriptExecutor)driver).executeScript("window.onbeforeunload = function() {};");

您可以在

这篇关于如何在Internet Explorer弹出窗口下方处理“确定要离开此页面?"通过硒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆