OS: Win 10
Chrome: 81.0.4044.129
ChromeDriver: 81.0.4044.69
Goal:
Load an existing profile with extensions and preference configured AND specify default download locations.
Purpose:
I want to save images into their respective folders name.
Challenges
If I specify a Chrome profile to be loaded, then I cannot change the default download folder.
Code Snippets:
# Loading profile works!
options = webdriver.ChromeOptions()
options.add_argument(f'user-data-dir={profile_path}')
options.add_argument(f'--profile-directory={profile_name}')
driver = webdriver.Chrome(chrome_options=options)
# Changing default download location works!
options = webdriver.ChromeOptions()
prefs = {"download.default_directory" : "C:/Downloads/Folder A"}
options.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(chrome_options=options)
# This DOESN'T work! Default download location is not changed.
options = webdriver.ChromeOptions()
options.add_argument(f'user-data-dir={profile_path}')
options.add_argument(f'--profile-directory={profile_name}')
prefs = {"download.default_directory" : "C:/Downloads/Folder A"}
options.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(chrome_options=options)
Is it possible to BOTH load the profile and change the default download location before the driver is created?