如何禁用“此类文件可能会损坏您的计算机"弹出窗口 [英] How to disable 'This type of file can harm your computer' pop up

查看:39
本文介绍了如何禁用“此类文件可能会损坏您的计算机"弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 selenium chromedriver 来自动化 Web 应用程序.在我的应用程序中,我需要下载 xml 文件.但是当我下载 xml 文件时,我会弹出这种类型的文件会损害您的计算机".我想使用 selenium chromedriver 禁用此弹出窗口,并且我希望始终下载这些类型的文件.如何才能做到这一点?

I'm using selenium chromedriver for automating web application. In my application, I need to download xml files. But when I download xml file, I get 'This type of file can harm your computer' pop up. I want to disable this pop up using selenium chromedriver and I want these type of files to be downloaded always. How can this be done?

  • 硒版本:2.47.1
  • Chrome 驱动版本:2.19

更新它是 长期存在的 Chrome 错误 从 2012 年开始.

UPDATE it's long standing Chrome bug from 2012.

推荐答案

从 Chrome 47.0.2526.80 m 开始,XML 文件的问题开始发生在我身上.在花了大约 6 个小时试图关闭所有可能的安全选项后,我尝试了一种不同的方法.

The problem with XML files started to happen to me as of Chrome 47.0.2526.80 m. After spending maybe 6 hours trying to turn off every possible security option I tried a different approach.

具有讽刺意味的是,似乎打开 打开 Chrome 选项 保护您和您的设备免受危险网站的侵害" 会删除消息 这种类型的文件可能会造成危害您的计算机.您仍然要保留 file.xml 吗?"

Ironically, it seems that turning on the Chrome option "Protect you and your device from dangerous sites" removes the message "This type of file can harm your computer. Do you want to keep file.xml anyway?"

我将Ruby"与Watir-Webdriver"一起使用,代码如下所示:

I am using 'Ruby' with 'Watir-Webdriver' where the code looks like this:

prefs = {
    'safebrowsing' => {
        'enabled' => true,
    }
}

b = Watir::Browser.new :chrome, :prefs => prefs

像这样启动浏览器,启用 safebrowsing 选项,下载 xml 文件而没有消息警告.Selenium 与任何编程语言的原理都应该相同.

Starting the browser like this, with safebrowsing option enabled, downloads the xml files without the message warning. The principle should be the same for Selenium with any programming language.

#####编辑日期:13-04-2017

在最新版本的谷歌浏览器中,上述解决方案是不够的.此外,需要使用以下开关启动浏览器:

In latest version of Google Chrome the above solution is not enough. Additionally, it is necessary to start the browser with the following switch:

--safebrowsing-disable-download-protection

现在,启动浏览器的代码如下所示:

Now, the code for starting the browser would look something like this:

b = Watir::Browser.new :chrome, :prefs => prefs, :switches => %w[--safebrowsing-disable-download-protection]))

这篇关于如何禁用“此类文件可能会损坏您的计算机"弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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