How to spcify the download location for IE11 and edge browsers using Selenium bindings

1.1k views Asked by At

Selenium C# bindings have the ability to specify the chrome download location:

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

Does any appropriate realization exist for Edge & IE11?

2

There are 2 answers

0
Pritam Maske On BEST ANSWER

IE does not use profiles.As such, there is no way to automatically download files to a specified location with Internet Explorer.

0
Sivaranjani Soundarraj On

For Edge try the following for changing the default download location:

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);