Question about OnDownload and timeouts

Hi there,

In the web application I’m testing, there is a button to download the results of a database query as a CSV file. Clicking the button queries the database, generates the CSV file and then serves the file up to the browser as a download. Depending on the complexity of the query, it can take a few seconds (sometimes more than 10) to generate the file and for the browser to start the download.

I use onDownload | | true in my macro so that I capture the original filename and wait for the download to finish before continuing.

Sometimes, because the file generation takes longer than 10 seconds, my macro errors with the “download start expired” message.

I tried setting the !TIMEOUT_DOWNLOAD variable to 300, but I’m guessing this is in cases where the size of the file is large and the actual download process takes a long time? My issue is that, after calling OnDownload, the macro clicks the button, but the download might not start for a while…

I’m also not sure whether !TIMEOUT_WAIT is supposed to help as I don’t see the little countdown on the UI.Vision Extension icon in Chrome when the macro clicks the download button.

What is the correct way for me to click a button to initiate a download and not have the macro time out if the download takes longer than expected to start?

I hope that all makes sense. Thanks!

Please give it a try by setting !TIMEOUT_WAIT to e. g. 300 seconds. → Does this help?

Yes, the !TIMEOUT_DOWNLOAD value is for the actual file download time.

I have the same issue and I think there is no way you can tell the script when the download is ready to pick up.

What I do, I put a “pause” command in as I know the file is usually ready to download within 10 seconds. But if your download can take longer and the time is unpredictable, a pause button might not be the right way to go.

If you see any refresh on your web page with new content to show when the file is ready to download you can try to capture the appearance of that new content to start the download.

Thanks @noahhath, I had considered adding a pause, but wasn’t sure where to put it! Do you click the download button, then pause, then have the onDownload? My concern is that sometimes the download is instant (a lot depends on whether the service behind the API has recently been used and is “spun up”) and sometimes it can take 10-15 seconds. If I pause the macro for too long, the download might have already happened before the OnDownload command is reached! Not sure what would happen then…

Ideally, there would be a way to specifically configure the timeout period for the download to start. Or, for the OnDownload command to respect the !TIMEOUT_WAIT value.

Thanks for confirming @admin. I have set !TIMEOUT_WAIT to 300 seconds, but unfortunately, the last two times I have run the test, the download has happened within a few seconds, so wouldn’t have caused the problem, so I’ve not been able to confirm anything!

However, my guess is that !TIMEOUT_WAIT doesn’t apply to OnDownload. I say this because the timer doesn’t appear in the browser UI.Vision icon, ticking down from 300, like it does elsewhere, when OnDownload is called.

As I’ve noted in my other reply, it would be great if !TIMEOUT_WAIT could be confirmed as the definitive answer, or if there was a specific !TIMEOUT_DOWNLOAD_START value we could configure. I guess only the UI.Vision devs can tell us what leads to the Download Start Expiry error and whether that period could be configurable.

Hi,

I do not use onDownload at all. I have played a little bit around with it but it seemed not to work for me. So what I do:

  1. Pause script for 10 seconds for the download menu shows up( I could waste 8 seconds if the download is ready earlier)
  2. Press enter key (automated kantu, so I have to make sure I stay on the website while all this happen)
  3. Pause again for 5 seconds seconds to wait the download is finished and the download window disappeared
  4. Move on with the script to do the next download.