I am doing a selenium test in python where I want to create a new directory with current time and make it as default download folder. So whenever I run the script the default download location should be a new directory created at that time and the file should download there.
from selenium import webdriver
from datetime import datetime
import os
today = datetime.now()
current_dir = os.mkdir("/Users/Desktop/" + today.strftime('%Y-%m-%d_%H-%M-%S'))
browser = webdriver.Chrome('/Users/Desktop/chromedriver')
chromeOptions = webdriver.ChromeOptions()
prefs = {"download.default_directory" : current_dir }
chromeOptions.add_experimental_option("prefs",prefs)
I am running the above script and it creates a new folder but the default download location doesn't change as the file still downloads at chrome://Downloads. Is there any way we can change the new created folder as default download directory