Not able to download file in chrome browser in headless mode? | Selenium Forum
M
Manjunath Reddy M S Posted on 03/03/2020

M
Manjunath Reddy M S Replied on 03/03/2020

As part of headless execution, download is not happening using chrome browser, can anybody, please help on this

 


A
Ashish Thakur Replied on 04/03/2020

Please try the below code.

String downloadFilepath = "/path/to/download";
HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
chromePrefs.put("profile.default_content_settings.popups", 0);
chromePrefs.put("download.default_directory", downloadFilepath);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", chromePrefs);
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(cap);

Reference: https://stackoverflow.com/questions/34515328/how-to-set-default-download-directory-in-selenium-chrome-capabilities


Related Posts