0
美好的一天。C#:Firefox webdriver:如何將文件下載到特定文件夾
我嘗試設置firefox webdriver的選項以下載到特定的foler。我把我的代碼放在下面。它在最後一行引發TypeInitializationException。
如何設置文件下載的默認文件夾,並設置它應該沒有警報窗口?
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);
對於Chrome路徑接受並正常工作。我使用FirefoxProfile.SetPreference,但它也不起作用。文件仍下載到'C:\ Users \ User \ AppData \ Local \ Temp' – Evgeniy175