pythonselenium-webdriverselenium-chromedriverui-automation

Chrome 122 - How to allow insecure content? (Insecure download blocked)


I'm unable to test file download with Selenium (python), after Chrome update to the version '122.0.6261.70'.

Previously running Chrome with the '--allow-running-insecure-content' arg did a trick. The same is suggested over the net. On some sites one additional arg is suggested: '--disable-web-security'.

But both change nothing for me (the warning keeps appearing).

Does anybody know if something has been changed between the 121 and 122 versions?

Is there some arg or pref that I'm missing?

Warning image for the reference:

enter image description here


Driver creation (simplified):
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
for arg in ["--allow-running-insecure-content", "--disable-web-security"]:
    options.add_argument(arg)
driver = webdriver.Chrome(options=options)

Solution

  • Okay, so found two solutions:

    1. --unsafely-treat-insecure-origin-as-secure=*
      This is an experimental flag that allows you to list which domains to treat as secure so the download is no longer blocked.
    2. --disable-features=InsecureDownloadWarnings
      This is a more stable flag that disables the insecure download blocking feature for all domains.

    --

    This is what worked for me:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    chrome_options = Options()
    chrome_options.add_argument("--window-size=1920,1080")
    chrome_options.add_argument("--allow-running-insecure-content")  # Allow insecure content
    chrome_options.add_argument("--unsafely-treat-insecure-origin-as-secure=http://example.com")  # Replace example.com with your site's domain
    chrome_options.add_experimental_option("prefs", {
        "download.default_directory": download_path,
        "download.prompt_for_download": False,
        "download.directory_upgrade": True,
        "safebrowsing.enabled": True
    })
    
    driver = webdriver.Chrome(options=chrome_options)