I am downloading several different data sets and would like each file (or set) to download to a specific folder. I have learned how to change the download directories at the
In the past, I have solved this by downloading to a temp folder and then renaming the file to the appropriate folder with something along the line of this:
def move_to_download_folder(downloadPath, newFileName, fileExtension):
got_file = False
## Grab current file name.
while got_file = False:
try:
currentFile = glob.glob(DOWNLOAD_PATH+"*"+fileExtension)
got_file = True
except:
print "File has not finished downloading"
time.sleep(20)
## Create new file name
fileDestination = downloadPath+newFileName+fileExtension
os.rename(currentFile, fileDestination)
return
## Click element to download file
inputElement=driver.find_element_by_xpath("{xpath here}").click()
move_to_download_folder(downloadPath, newFileName, fileExtension)