To Change the default download directory in chrome using WebDriver Java Bindings and ChromeDriver.
1
2
3
4
5
6
7
8
9
| ChromeOptions options=new ChromeOptions();
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_settings.popups", 0);
prefs.put("download.default_directory", "D:\\downloads");
prefs.put("savefile.default_directory", "D:\\downloads");
options.setExperimentalOption("prefs", prefs);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(capabilities);
|
To Use a custom profile in ChromeDriver which can be utilized for many use cases:
1
2
3
4
5
| ChromeOptions options=new ChromeOptions();
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
chromeoptions.addArguments("user-data-dir="+chromeprofilepath);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(capabilities);
|
No comments:
Post a Comment