chorme 下载文件 保留 放弃_使用硒自定义Chrome浏览器驱动程序来保存文件,而不会在下载时提示保存或放弃文件...

I am trying to automate downloading files using selenium with chrome as my browser using chromedriver. When i try downloading exe files its prompting me "This type of file can harm your computer, Discard or save it". i want it to download anyway without any prompt.

I have looked into few solutions like below:

chromeOptions = webdriver.ChromeOptions()

prefs = {"browser.helperApps.alwaysAsk.force" :False,"browser.helperApps.neverAsk.saveToDisk" : "application/octet-stream"}

chromeOptions.add_experimental_option("prefs",prefs)

browser = webdriver.Chrome(executable_path=//path//to//chrome_driver, chrome_options=chromeOptions)

But this didn't help it still throws up the prompt.

Any help on this is greatly appreciated.

Thanks,

解决方案

From what I understand, there is no way to tell Chrome not to warn on potentially dangerous binary file downloads, see:

As the simplest workaround, you might want to approach the problem with Firefox:

Also there have been numerous requests from dev community to allow to

disable this warning to be able to run automated tests in Chrome. At

the moment this is the only reason we're running our automated tests

in Firefox only. Really annoying.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值