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 的弹出窗口
基础教程推荐
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 直接将值设置为滑块 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01