Change download path of Firefox Driver

I am writing some automated tests using the Java based Selenium Firefox driver. In one of my tests I have to download and verify a PDF file. But the Firefox Driver downloads the file in the default download folder. I want to download the file in a different folder. Is it possible to change the location where the file should be downloaded?


Thanks for the Details answer, I had an issue regarding the Same topic and I was able to solve it with the provided solution
Moritz Ruoff Holzer - Wed, 12/22/2021 - 06:22 :::
1 answer

Yes it is possilbe to change the download folder. You have to specify that in the FirefoxProfile before you initialize the Firefox Driver:

FirefoxOptions options = new FirefoxOptions();
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("","your folder");
FirefoxDriver driver = new FirefoxDriver(options);


I actually haven't had to change the download path of Firefox Driver so far, but if I run into a similar problem while testing, your solution will certainly help me! Thanks for sharing!

Anna Lackinger - Wed, 12/15/2021 - 08:37 :::

I would also add a note that if you change default download directory manually through browser setting, it will not be same when selenium scripts launch a browser. Selenium launch browser with default settings.

Mesa Islamovic - Wed, 12/22/2021 - 11:41 :::