selenium 测试用例单击 http 下载链接,并在 Chrome v124 中被阻止下载,并显示 UI 消息“不安全下载被阻止”。
我有以下 Chrome 配置集 - 适用于 Chrome v123。需要更改哪些内容才能使 v124 不阻止不安全的下载?
service = Service()
options = webdriver.ChromeOptions()
options.add_argument('--disable-dev-shm-usage')
options.add_argument('disable-notifications')
options.add_argument('--disable-features=InsecureDownloadWarnings')
options.add_argument('--disable-web-security')
options.add_argument('--allow-running-insecure-content')
options.add_experimental_option("prefs", {
"download.default_directory": testcase_download_directory,
"download.prompt_for_download": False,
"plugins.always_open_pdf_externally": True,
"safebrowsing.disable_download_protection": True,
"safebrowsing.enabled": False,
"profile.default_content_setting_values.automatic_downloads": 1
})
这成功了:
options.add_argument("--unsafely-treat-insecure-origin-as-secure=http://example.com")