I\'m using Selenium Webdriver (in Python) to automate the downloading of thousands of files. I want to set Chrome\'s download folder programmatically. After reading this, I
Note: Both .py file and Folder "PDF_Folder" in same location and file should download in Folder "PDF_Folder"
exepath = sys.arg[0]
# get the path from the .py file
Dir_path = os.path.dirname(os.path.abspath(exepath))
# get the path of "PDF_Folder" directory
Download_dir = Dir_path+"\\PDF_Folder\\"
preferences = {"download.default_directory": Download_dir , # pass the variable
"download.prompt_for_download": False,
"directory_upgrade": True,
"safebrowsing.enabled": True }
chrome_options.add_experimental_option("prefs", preferences)
driver = webdriver.Chrome(chrome_options=chrome_options,executable_path=r'/pathTo/chromedriver')
driver.get("urlfiletodownload");