0

I was able to change the download location in Chrome but when I do it for Edge browser the method setExperimentalOptions is not present for EdgeOptions. I am using Selenium 3.141.59 Java.

String location = System.getProperty("user.dir") + "\\Downloads";

HashMap preferences = new HashMap();
preferences.put("download.default_directory", location); 
          
EdgeOptions options = new EdgeOptions();
options.setExperimentalOption("prefs", preferences); //setExperimentalOption is not existed for Edge
        
System.setProperty("webdriver.edge.driver","C:\\Users\\User\\Desktop\\Selenium\\Browsers\\Edge\\msedgedriver.exe");
WebDriver driver = new EdgeDriver(options);
         
driver.manage().window().maximize();
driver.get("https://file-examples.com/index.php/sample-documents-download/sample-doc-download/");

driver.findElement(By.xpath("//tbody/tr[1]/td[5]/a[1]")).click();

itronic1990
  • 1,231
  • 2
  • 4
  • 18

1 Answers1

0

Selenium 3.141.59 the method setExperimentalOptions is undefined, after checking the Selenium EdgeDriver library I'm not finding any specific way to change the download location.

In this case, I can suggest you use the Selenium 4.0.0-beta-4 where the the .setExperimentalOption() is been defined.

YaDav MaNish
  • 1,260
  • 2
  • 12
  • 20