I would like to ask if someone has tried to change the default download location on Microsoft Edge Chromium driver using selenium 3.X. On Chrome browser, we could use something
Try using the following setup (Java Bindings):
public WebDriver newDriver() {
try {
EnvironmentVariables vars = SystemEnvironmentVariables.createEnvironmentVariables();
String version = vars.getProperty("webdriver.edgedriver.version");
WebDriverManager.edgedriver().version(version).setup();
EdgeOptions options = new EdgeOptions();
EdgeDriverService edgeDriverService = EdgeDriverService.createDefaultService();
EdgeDriver edgeDriver = new EdgeDriver(edgeDriverService, options);
final String downloadPath = ${your path}
//************* Enable downloading files / set path *******************
Map<String, Object> commandParams = new HashMap<>();
commandParams.put("cmd", "Page.setDownloadBehavior");
Map<String, String> params = new HashMap<>();
params.put("behavior", "allow");
params.put("downloadPath", downloadPath);
commandParams.put("params", params);
ObjectMapper objectMapper = new ObjectMapper();
HttpClient httpClient = HttpClientBuilder.create().build();
String command = objectMapper.writeValueAsString(commandParams);
String u = edgeDriverService.getUrl().toString() + "/session/" + edgeDriver.getSessionId() + "/chromium/send_command";
HttpPost request = new HttpPost(u);
request.addHeader("content-type", "application/json");
request.setEntity(new StringEntity(command));
httpClient.execute(request);
return edgeDriver;
} catch (Exception e) {
throw new Error(e);
}
}
I was able to download files to the desired path using this snippet. Source here