Possible Duplicate:
Access to file download dialog in Firefox
I'm using selenium and firefox to download a file from the internet.
When i'm trying to download the file, i'm getting the download box which asking me if i want to save the file or "open with".
I want to save the file but not automatically (want to rename the file name), i want the browser will ask me where to save the file.
This option of "always ask where to save files" at the firefox settings is selected and still.. when i'm running the script with selenium it is not asking me and saving the file.
How can i set the firefox profile to do this? and where can i see the all firefox profiles?
THanks for helpers.
Investigated a lil bit workaround of the problem. Would like to share what I found.
Concerning automation browser dialog boxes using Selenium in general:
There is no easy way to make Selenium download files because browsers use native dialogs for it which cannot be controlled by JavaScript, so you need some "hack".
Check this
Concerning ffox browser settings in particular, you can configure Firefox to automatically start the download and save the file in a specific place.
Or use that:
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("browser.download.folderList",2);
firefoxProfile.setPreference("browser.download.manager.showWhenStarting",false);
firefoxProfile.setPreference("browser.download.dir","c:\\downloads");
firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv");
WebDriver driver = new FirefoxDriver(firefoxProfile);//new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
driver.navigate().to("http://www.myfile.com/hey.csv");
Hope this works for you
The firefox profile which selenium uses is with the default options firefox comes with.You will have to set the option to ask for, where to save file, in the selenium code.