Forum Discussion

IAmSanjay's avatar
IAmSanjay
New Contributor
7 years ago

Is there wait method for download to complete?

I want to pause the test complete execution until the file downloading completes. 

How can I do that?

  • I'm assuming you're talking about when you download a file from a website?

     

    There isn't anything native in TestComplete to "wait for a download" so you'll have to code something yourself.  There are several ways of doing so that come to mind off the top of my head.

     

    1) You could use some form of the aqFileSystem object to check for the downloaded file... when it's fully downloaded, the file should exist so just loop through until the file exists.

    2) If your web site has some sort of dialog or indicator on the page to indicate that the download is complete, you can loop through a Wait process to check for that indicator.

    3) You could interact with your browser directly to see what options there are to interact with downloading files.  Once you find that method, you can use some sort of detection within your browser similar to #2 to indicate that the download is complete.

     

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    I'm assuming you're talking about when you download a file from a website?

     

    There isn't anything native in TestComplete to "wait for a download" so you'll have to code something yourself.  There are several ways of doing so that come to mind off the top of my head.

     

    1) You could use some form of the aqFileSystem object to check for the downloaded file... when it's fully downloaded, the file should exist so just loop through until the file exists.

    2) If your web site has some sort of dialog or indicator on the page to indicate that the download is complete, you can loop through a Wait process to check for that indicator.

    3) You could interact with your browser directly to see what options there are to interact with downloading files.  Once you find that method, you can use some sort of detection within your browser similar to #2 to indicate that the download is complete.

     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    One possible approach is to wait until the file appears on the hard drive and then try in a loop to open it for writing (using aqFile.Open()). Usually, OS blocks attempt to open file for writing until it completely downloaded/copied/etc. and all caches are flushed.