Being able to save files in Selenium seems to be a common problem for users of that framework. Here is a helper method to get a Firefox driver with preferences set to allow download:


	public static WebDriver getDownloadCapableBrowser(File tempDir)
			throws IOException {
		boolean dirExists = tempDir.exists();

		assertTrue("Directory does not exist", dirExists);
		FirefoxProfile fp = new FirefoxProfile();
		try {
			fp.setPreference("", 2);
			fp.setPreference("", false);
			fp.setPreference("", tempDir.getCanonicalPath());
			fp.setPreference("browser.helperApps.alwaysAsk.force", false);

		} catch (IOException e) {
			throw new IOException(
					"Failed to initialize Firefox with temp directory for downloads",

		WebDriver driver = new FirefoxDriver(fp);

		return driver;