C#: Firefox webdriver: How to download file to a specific folder
<p>Good day.</p>

<p>I try to set up options for firefox webdriver for download to a specific foler. I put my code below. It's throws TypeInitializationException on last line.</p>

<p>How i can set default folder for file download and set that it should be without alert window?</p>

<pre><code>var firefoxOptions = new FirefoxOptions();
firefoxOptions.AddAdditionalCapability("browser.download.folderList", 2);          firefoxOptions.AddAdditionalCapability("browser.download.manager.showWhenStarting", false);
firefoxOptions.AddAdditionalCapability("browser.download.dir", Constants.DownloadFilesLocation);
firefoxOptions.AddAdditionalCapability("browser.helperApps.neverAsk.saveToDisk", "image/jpeg");
firefoxOptions.AddAdditionalCapability("browser.helperApps.neverAsk.saveToDisk", "image/png");
firefoxOptions.AddAdditionalCapability("browser.helperApps.neverAsk.saveToDisk", "image/gif");
firefoxOptions.AddAdditionalCapability("browser.helperApps.neverAsk.saveToDisk", "image/bmp");
firefoxOptions.AddAdditionalCapability("browser.helperApps.neverAsk.saveToDisk", "image/tiff");
Driver = new FirefoxDriver(firefoxOptions);
</code></pre>