How do i change the default download directory in the current running driver session? as i need to change the download directory many times to store particular file at particular location using 'for' loop.
below are the code which the tried to change the default directory of already running chrome driver session:
os.getcwd()
os.chdir("C:\\Site_tracker\\Output")
direc = ['S1_2g3g4g', 'S2_2g3g4g','S3_2g3g4g']
for i in direc:
if not os.path.exists(i):
os.makedirs(i)
download_path=os.path.abspath(i)
print(download_path)
chr_Options.add_experimental_option('prefs', {
"download.default_directory": "download_path", #Change default directory for downloads
"download.prompt_for_download": False, #To auto download the file
"download.directory_upgrade": True,
"plugins.always_open_pdf_externally": True})
driver1=webdriver.Chrome(chrome_options=chr_Options)