I need to download a file to a given location on a non-local machine. This is the normal flow of the web browser for which I would do this:
Use selenium webdriver
Use firefox profile to download your files. This profile skip that dialogue box of firefox. In line:-
pro.setPreference("browser.downLoad.folderList", 0);
The value of browser.download.folderList can be set to either 0, 1, or 2. When set to 0, Firefox will save all files downloaded via the browser on the user's desktop. When set to 1, these downloads are stored in the Downloads folder. When set to 2, the location specified for the most recent download is utilized again.
Firefox profile code that you need to implement :-
FirefoxProfile pro=new FirefoxProfile();
pro.setPreference("browser.downLoad.folderList", 0);
pro.setPreference("browser.helperApps.neverAsk.saveToDisk", "Applications/zip");
WebDriver driver=new FirefoxDriver(pro);
driver.get("http://selenium-release.storage.googleapis.com/2.47/selenium-java-2.47.1.zip");
Hope it will help you :)