【问题标题】:Which preference can I add in python selenium ChromeDriver options to allow unsafe-downloads?我可以在 python selenium ChromeDriver 选项中添加哪个首选项以允许不安全下载?
【发布时间】:2020-12-12 12:28:46
【问题描述】:

现在我必须禁用以下 Chrome 标志:

chrome://flags/#treat-unsafe-downloads-as-active-content

我可以在webdriver.ChromeOptions 中使用哪些首选项,比如"profile.managed_default_content_settings.images": 2,而不是修改标志?

【问题讨论】:

    标签: python selenium selenium-chromedriver


    【解决方案1】:
     safebrowsing.enabled:false
    

    将此标志设置为 false ,

    参考: https://support.google.com/chrome/thread/24751883?hl=en

    以下链接显示支持的首选项位于 chrome 选项中:

    https://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/pref_names.cc?view=markup

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    chrome_options = Options()
    chrome_options.add_experimental_option("prefs", {
      
      "safebrowsing.enabled": False
    })
    
    driver = webdriver.Chrome(options=chrome_options)
    

    【讨论】:

    • 它不起作用,错误:This file should be served over HTTPS. This download has been blocked. See https://blog.chromium.org/2020/02/protecting-users-from-insecure.html for more details.
    • 你可以试试 options.add_arguments("--allow-running-insecure-content")
    • 非常感谢,但还是没有出现同样的错误
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-29
    相关资源
    最近更新 更多