Skip to content Skip to sidebar Skip to footer

Multiple Download Folders Using Selenium Webdriver?

I'm using the Selenium webdriver (in Python) to automate the donwloading of thousands of files. I want the files to be saved in different folders. The following code works, but it

Solution 1:

No, I don't think you can do it.

Option one: specify different default directories for one FirefoxProfile

You can't. In my opinion, this is the issue with Firefox, not Selenium. However, this Firefox limitation looks like the correct design to me. browser.download.dir is the default download destination, if it allows multiple directories, then that's not "default" anymore.

Option two: switch multiple FirefoxProfile for one driver instance

If not doing it in Firefox, can FirefoxProfile be switched for same driver instance? As far as I know, the answer is no. (You have already done some research on this)

Option three: use normal non-Selenium way to do the downloading

If you want to avoid using this auto-downloading approach and do it the normal way (like Auto-it etc.), then it falls in the category of "How To Download Files With Selenium And Why You Shouldn’t". But in this case, your code can be simplified.

some_list = ["item1", "item2", "item3"] # over 300 items on the actual code
for item in some_list:
    download_folder = "/Users/myusername/Desktop/" + item
    some_way_magically_do_the_downloading(download_folder)

Post a Comment for "Multiple Download Folders Using Selenium Webdriver?"