1

Selenium C# 绑定能够指定 chrome 下载位置:

var options = new ChromeOptions().AddUserProfilePreference("download.default_directory", "D:\Downloads");

Edge 和 IE11 是否存在任何适当的实现?

4

2 回答 2

0

IE 不使用配置文件。因此,无法使用 Internet Explorer 自动将文件下载到指定位置。

于 2018-04-24T19:00:55.203 回答
0

对于 Edge,请尝试以下更改默认下载位置:

EdgeOptions options = new EdgeOptions();
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_settings.popups", 0);
prefs.put("download.default_directory",
System.getProperty("user.dir")+"\\downloads");
prefs.put("download.prompt_for_download", false);
Map<String, Object> edgeOptions = new HashMap<String, Object>();
edgeOptions.put("prefs", prefs);
edgeOptions.put("useAutomationExtension", false);
options.setCapability("ms:edgeChrominum", true);
options.setCapability("ms:edgeOptions", edgeOptions);
WebDriver driver = new EdgeDriver(options);
于 2021-03-04T17:19:58.367 回答