pythonselenium

python selenium, find out when a download has completed?


I've used selenium to initiate a download. After the download is complete, certain actions need to be taken, is there any simple method to find out when a download has complete? (I am using the FireFox driver)


Solution

  • There is no built-in to selenium way to wait for the download to be completed.


    The general idea here would be to wait until a file would appear in your "Downloads" directory.

    This might either be achieved by looping over and over again checking for file existence:

    Or, by using things like watchdog to monitor a directory: