带有 MS Edge Beta (v91) 的 Selenium 不会在没有提示的情况下下载 XML 文件(此类文件可能会损害您的设备) [英] Selenium with MS Edge Beta (v91) does not download XML files without prompt (this type of file can harm your device)

查看:62
本文介绍了带有 MS Edge Beta (v91) 的 Selenium 不会在没有提示的情况下下载 XML 文件(此类文件可能会损害您的设备)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题开始在 MS Edge Chromium Beta v91 (91.0.864.15) 上重现.此浏览器于本周五,4 月 30 日发布.

This issue starts to reproduce against MS Edge Chromium Beta v91 (91.0.864.15). This browser was released this Friday, April, 30.

当我的 Selenium 测试尝试下载 XML 文件时 - 文件未下载.浏览器会显示类似这种类型的文件可能会损害您的设备"之类的警告.当我尝试在同一个测试中下载其他文件类型(PDF、DOC)时 - 这些文件下载成功.IE.我的 Edge 选项允许在没有额外提示的情况下下载文件(并且它在 Edge v90 中也能正常工作).我目前的边缘选项是:

When my Selenium test tried to download an XML file - file did not downloaded. Browser shows warning like "this type of file can harm your device". When I tried to download another file types in the same test (PDF, DOC) - these files downloaded successfully. I.e. my Edge options allows to download file without additional prompt (and it also works correctly in Edge v90). My current Edge Options are:

options.AddUserProfilePreference("download.prompt_for_download", false);
options.AddUserProfilePreference("download.default_directory", "C:\MyDir");
options.AddUserProfilePreference("safebrowsing.enabled", true);  //also tried with 'false' - still not working
options.AddArguments("--safebrowsing-disable-download-protection");
options.AddArguments("safebrowsing-disable-extension-blacklist");

看起来,微软为此在 Edge v91 中添加了一些额外的参数.您知道吗,我应该为 Edge 91 版使用什么 MS Edge 选项来在没有提示的情况下处理 Selenium 测试中的 XML 文件下载?

Looks like, Microsoft have added some additional argument into Edge v91 for this. Do you know, what MS Edge option should I use for Edge version 91 to handle XML files download in Selenium tests without prompt?

推荐答案

是的,现在似乎无法通过 Edge 选项对其进行配置.作为解决方法,我使用了以下 powershell 脚本来更新 Windows 注册表:

Yeah, looks like it is not possible now to configure it via Edge options. As workaround, I have use the following powershell script, which update Windows Registry:

$regpath="HKLM:\Software\Policies\Microsoft\Edge\ExemptDomainFileTypePairsFromFileTypeDownloadWarnings"

if (!(Test-Path $regpath)) {
    New-Item -Path $regpath -Force
}

New-ItemProperty -Path $regpath -Name "1" -Value '{"domains": ["*"], "file_extension": "xml"}' -PropertyType String -Force

这篇关于带有 MS Edge Beta (v91) 的 Selenium 不会在没有提示的情况下下载 XML 文件(此类文件可能会损害您的设备)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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