Dismiss quot;Confirm Navigationquot; popup with Watir(关闭“确认导航Watir 的弹出窗口)
问题描述
我正在尝试关闭确认导航"弹出窗口.这就是它在 Chrome 中的样子.
I am trying to dismiss "Confirm Navigation" popup. This is how it looks like in Chrome.
要查看弹出窗口:
require "watir-webdriver"
browser = Watir::Browser.new
browser.goto "http://www.gravityforms.com/demo/wp-admin/admin.php?page=gf_new_form"
browser.text_field(:id => "user_login").set "demo"
browser.text_field(:id => "user_pass").set "demo"
browser.button(:id => "wp-submit").click
browser.refresh
目前,当我访问该页面时,我会覆盖 onbeforeunload
,正如 http 中所建议的那样://watirwebdriver.com/javascript-dialogs/
At the moment I override onbeforeunload
when I visit the page, as suggested at http://watirwebdriver.com/javascript-dialogs/
browser.execute_script("window.onbeforeunload = function() {};")
所以,脚本现在看起来像这样:
So, the script now looks like this:
require "watir-webdriver"
browser = Watir::Browser.new
browser.goto "http://www.gravityforms.com/demo/wp-admin/admin.php?page=gf_new_form"
browser.text_field(:id => "user_login").set "demo"
browser.text_field(:id => "user_pass").set "demo"
browser.button(:id => "wp-submit").click
browser.execute_script("window.onbeforeunload = function() {};")
browser.refresh
而且效果很好.我只是想知道是否有更好的解决方案.
And it works just fine. I am just wondering if there is a better solution.
推荐答案
我认为这是目前最好的方法.
I think that's the best way for now.
大约两个月前,我为此提交了 bug/feature-request.如果这会让您的事情变得更轻松,您可能想在那里发表评论并投支持票.
I filed a bug/feature-request for this about two months back. You might want to comment there and add a vote of support if it's something that would make things easier for you.
这篇关于关闭“确认导航"Watir 的弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:关闭“确认导航"Watir 的弹出窗口


基础教程推荐
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01