Ask a Question

Is there wait method for download to complete?

SOLVED
IAmSanjay
New Contributor

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?

1 ACCEPTED SOLUTION

Accepted Solutions
tristaanogre
Community Hero

Re: Is there wait method for download to complete?

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.

 


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

2 REPLIES 2
tristaanogre
Community Hero

Re: Is there wait method for download to complete?

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.

 


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

AlexKaras
Community Hero

Re: Is there wait method for download to complete?

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.

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
cancel
Showing results for 
Search instead for 
Did you mean: