- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在 chrome 浏览器上运行自动(python)selenium 测试,有时当页面重新加载时,屏幕上会出现一个弹出窗口:
是否有可能以这种方式配置 chrome selenium 浏览器,使此弹出窗口不出现?如果是这样,该怎么做?还是有其他方法可以抑制此弹出窗口?还是接受?
最佳答案
此弹出窗口的文本为重新加载站点?您所做的更改可能无法保存 是 WindowEventHandlers 的 onbeforeunload
属性的实现。
onbeforeunload WindowEventHandlers 的属性(property)mixin 是 EventHandler加工beforeunload事件。这些事件在窗口即将变为 unload 时触发。它的资源。此时,文档仍然可见,事件仍然可以取消。
有不同的策略可用于处理此弹出。
Chrome 解决方案:通过 ChromeOptions() 使用 --disable-popup-blocking
:
from selenium import webdriver
options.add_argument("--disable-popup-blocking")
driver=webdriver.Chrome(chrome_options=options, executable_path=/path/to/chromedriver')
Firefox 解决方案:通过 FirefoxProfile() 使用 dom.disable_beforeunload
:
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preference("dom.disable_beforeunload", True)
driver = webdriver.Firefox(firefox_profile = profile)
跨浏览器解决方案:作为跨浏览器解决方案,您可以禁用此对话框调用executeScript()
来设置< em>window.onbeforeunload as function() {};
并且您可以使用以下解决方案:
driver.execute_script("window.onbeforeunload = function() {};")
基于 JQuery 的解决方案:
$I->executeJS( "window.onbeforeunload = null" );
You can find a relevant discussion in How to handle below Internet Explorer popup “Are you sure you want to leave this page?” through Selenium
关于javascript - 如何为 chrome 中的(python) Selenium 测试禁用 "Reload site? Changes you made may not be saved"弹出窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55587025/
谁能告诉我 Core-site.xml、hdfs-site.xml、mapred-site.xml 和 yarn-site.xml 必须具备的属性,没有这些属性 hadoop 就无法启动? 最佳答案
由于特定的 problem我设法解决了这个问题,我今天大部分时间都在弄清楚 site.py(s) 是如何工作的。有一点我不明白。 据我了解,当加载 python 时,首先运行 lib/python2.
这个问题在这里已经有了答案: Using async/await with a forEach loop (33 个答案) 关闭 4 年前。 我认为我的 driver.get(site) 调用设置错
与hadoop api configuration on the client machine有关。 如果我们尝试将客户端计算机上的mapred-site.xml保持尽可能少=仅指定mapred.jo
我一直对site-packages的命名原理有些好奇。 site 在这种情况下是什么意思?我怀疑它的意思是“网站”,而且我从未听说过与安装位置或机器上下文相关的“站点”。 有什么想法吗? 最佳答案 我
我有一个本地 NiFi 实例,我想通过安全的站点到站点通信将数据发送到 AWS 服务器上的远程 NiFi 实例。 我使用 NiFi TLS 工具包为我的客户端和服务器 keystore 和信任库生成了
已关闭。这个问题是 not about programming or software development 。目前不接受答案。 这个问题似乎不是关于 a specific programming
我尝试按照说明在我的页面上设置 reCAPTCHA here 。我注册了 API key 对,并获得了公钥和私钥。对我来说,不清楚应该如何使用私钥,并且我无法找到有关它的更多信息。调用 reCAPTC
尝试我的第一个“HELLO WORLD”类型的 Web 应用程序,该应用程序基于显示 godaddy 设置的示例程序。 使用 Visual Studio 2017 和 C#。我的程序在 localho
我使用 HttpClient 从 Hadoop 服务器下载文件。 但其他人说这不利于安全,因为它不需要输入用户 ID。所以我必须将其更改为webhdfs或hdfs。 我必须连接 Hadoop,但它不是
去年,我根据 GitHub Pages' instructions 将我的博客设置为 GitHub 页面“用户站点”在遵循他们的命名约定 username.github.io 的 repo 中。但是,
我尝试了几天在 2 个站点之间创建 VPN 隧道,但没有成功。 场景 我有以下场景: 站点 A 的 IP 地址为 192.168.1.0/24,网关 GWA 的地址为 192.168.1.254 和
我们有一个 VSO 存储库,同一解决方案中包含多个站点。我们希望能够通过持续交付将彼此独立的站点部署到 Azure。现在,第一个站点按字母顺序部署到我们所有的站点,这当然是不可取的。 这可以实现吗?
我们有一个 VSO 存储库,同一解决方案中包含多个站点。我们希望能够通过持续交付将彼此独立的站点部署到 Azure。现在,第一个站点按字母顺序部署到我们所有的站点,这当然是不可取的。 这可以实现吗?
如何为查看者输入“站点”? Eclipse API 中的“站点”是什么? 我在SampleView中找到了以下代码: viewer.setInput(getViewSite()); 其中 viewer
在 The Django Book在关于管理站点的第 6 章中,他们告诉我将以下 URL 模式添加到 urls.py: urlpatterns = patterns('', # ...
我正在尝试安装站点包,并且在运行 makemigrations 时收到错误: django.contrib.admin.sites.AlreadyRegistered: The model Site
我正在尝试使用 Google Tag Manager对于使用 Google Sites 创建的站点,但到目前为止我还没有运气。这个问题似乎已经出现在几个论坛上,但我无法为此找到任何明确的答案。 帮助将
在我的电脑中: /etc/R 中有三个文件Renviron 和 Rprofile.site、Renviron.site 、我在任何地方都找不到Rprofile。这是一个适当的状态吗? Rprofile
我正在尝试安装站点包,并且在运行 makemigrations 时收到错误: django.contrib.admin.sites.AlreadyRegistered: The model Site
我是一名优秀的程序员,十分优秀!