Reputation: 353
I am using Selenium and Java to write tests for Chrome browser. At some point i need to download a file and I need to change the directory that file is gonna be downloaded to. the problem is that when I use the code snippet below it opens the popup window and I don't want it:
String downloadFilepath = "download";
HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
chromePrefs.put("download.default_directory", downloadFilepath);
options.setExperimentalOption("prefs", chromePrefs);
Upvotes: 2
Views: 980
Reputation: 3970
Can you try this?
String downloadFilepath = "download";
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("download.default_directory", downloadFilepath);
DesiredCapabilities caps = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
caps.setCapability(ChromeOptions.CAPABILITY, options);
Upvotes: 0
Reputation: 23805
Add below arguments as chromeOptions :-
options.addArguments("disable-popup-blocking")
Hope it will help you..:)
Upvotes: 1