Skip to content

Instantly share code, notes, and snippets.

@cnhappier
Created January 14, 2015 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cnhappier/d783922dd208f60fd974 to your computer and use it in GitHub Desktop.
Save cnhappier/d783922dd208f60fd974 to your computer and use it in GitHub Desktop.
Disable Save As dialog in Selenium ChromeDriver
public static WebDriver createWebDriver(String localPath)
{
System.setProperty("webdriver.chrome.driver", "D:/devtools/webdriver/2.13/chromedriver.exe");
Map<String, String> prefs = new Hashtable<>();
prefs.put("download.prompt_for_download", "false");
prefs.put("download.default_directory", localPath);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
return new ChromeDriver(capabilities);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment