Reputation: 347
I'm trying to change the default path for chrome downloads with selenium on powershell:
$savepath="path"
$ChromeOptions = New-Object OpenQA.Selenium.Chrome.ChromeOptions
$chromePrefs=@{"download.default_directory" = $savepath}
$ChromeOptions.AddAdditionalCapability("prefs",$chromePrefs)
$driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions)
But here is the error I get :
Exception calling "AddAdditionalCapability" with "2" argument(s): "There is already an option for the prefs capability. Please use the instead. Parameter name: capabilityName"
Thanks !
Upvotes: 1
Views: 1535
Reputation: 36
The correct way that worked for me:
$myMap = @{}
$myMap.Add("default_directory", "c:\temp")
$myMap.Add("prompt_for_download", $true)
$ChromeOptions.AddUserProfilePreference("download", $myMap)
Upvotes: 2