SOLVED

Set download directory via WebDriver

Copper Contributor

I'm using Edge v81.0.416.64 to run Selenium Tests using the matching Edge WebDriver, however it does not seem to be possible to set a custom download directory using the "download.default_directory" user profile preference, used in Chrome. I know that there is the option to change the download directory using group policies (https://docs.microsoft.com/en-us/DeployEdge/microsoft-edge-policies#downloaddirectory), but this is no viable option for web tests.

 

Am I missing something/is there another way? Is this something planned for the future?

 

EDIT: Setting the "download.default_directory" user profile preference works in Edge v79.0.309.65.

4 Replies

@Marcel_Holle we made some changes to MSEdgeDriver in v 81 that seem to be impacting your tests. Can you share the code sample for how you create the driver() object?

 

-John

Hi @johnjansen ,

 

we're using Selenium 3.141.0.0 & ChromeDriver classes:
 

 

var edgeOptions = new EdgeOptions
                  {
                      BinaryLocation = BrowserBinaryPath
                  };

DisableSpecCompliance (edgeOptions); // force "w3c" capability to false
AdjustBrowserNameCapability (edgeOptions); // Set DriverOptions.BrowserName to "MicrosoftEdge" instead of "Chrome"

edgeOptions.AddArgument ($"user-data-dir={userDirectory}");

edgeOptions.AddArgument ("no-first-run");
edgeOptions.AddArgument ("force-device-scale-factor=1");

edgeOptions.AddUserProfilePreference ("safebrowsing.enabled", true);
edgeOptions.AddUserProfilePreference ("download.default_directory", DownloadDirectory);

var driverService = ChromeDriverService.CreateDefaultService (driverDirectory, driverExecutable);
driverService.EnableVerboseLogging = false;
driverService.LogPath = logPath;

var driver = new ChromeDriver (driverService, _extendedEdgeOptions, commandTimeout);
driver.Manage().Timeouts().AsynchronousJavaScript = asyncJavaScriptTimeout;

 

best response confirmed by Marcel_Holle (Copper Contributor)
Solution

@Marcel_Holle thanks for the code, that helps so much. The issue is because you are using ChromeDriver() which is not supported on Edge 81 and newer. We wrote a pretty cool tool to enable this to work more seamlessly here: https://github.com/microsoft/edge-selenium-tools

 

Basically, it is fully backward compatible with the old Edge browser as well as the new Edge browser to try to help people save time writing new tests.

 

-John

Hi@johnjansen 

thank you so much, using Microsoft.Edge.SeleniumTools solved our issue.

1 best response

Accepted Solutions
best response confirmed by Marcel_Holle (Copper Contributor)
Solution

@Marcel_Holle thanks for the code, that helps so much. The issue is because you are using ChromeDriver() which is not supported on Edge 81 and newer. We wrote a pretty cool tool to enable this to work more seamlessly here: https://github.com/microsoft/edge-selenium-tools

 

Basically, it is fully backward compatible with the old Edge browser as well as the new Edge browser to try to help people save time writing new tests.

 

-John

View solution in original post