# How do you check that a browser download has finished before opening the file?

**URL:** <https://forum.robotframework.org/t/how-do-you-check-that-a-browser-download-has-finished-before-opening-the-file/9893>\
**Category:** Browser\
**Created:** [5 November 2026 03:52 UTC](https://forum.robotframework.org/t/how-do-you-check-that-a-browser-download-has-finished-before-opening-the-file/9893 "2026-11-05T03:52:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ameliablake1201](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@ameliablake1201](https://forum.robotframework.org/u/ameliablake1201)\
**Post date:** [5 November 2026 03:52 UTC](https://forum.robotframework.org/t/how-do-you-check-that-a-browser-download-has-finished-before-opening-the-file/9893/1 "2026-11-05T03:52:19Z")

</div>

I’m designing a Browser-library check for a page that exports an image. The test needs to click Download and then open the resulting file. A file from an earlier run could have the same name, so finding that name in the download directory would be a weak check.

My intended sequence is to start listening for the download before clicking, use a fresh destination for the current run, and then try to decode the file. I’d like to keep the failure messages separate so a timeout waiting for the download looks different from an unreadable image.

Where do you draw that line in Robot Framework Browser? Is there a download keyword or result you rely on for completion before the image check starts? If you have a small example that handles a repeated filename, I’d be interested in how you set up the destination and which step reports a failed download.

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [5 November 2026 04:09 UTC](https://forum.robotframework.org/t/how-do-you-check-that-a-browser-download-has-finished-before-opening-the-file/9893/2 "2026-11-05T04:09:39Z")

</div>

Hi Amelia,

Welcome to the community,

I would suggest to use [Get Time](https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Get%20Time "Link to this keyword") keyword from the BuiltIn library to generate a timestamp variable, use that in the as part of the `saveAs` argument to the [Download](https://marketsquare.github.io/robotframework-browser/Browser.html#Download "Link to this keyword") keyword from Browser Library to control the file name of the file that’s downloaded, then your can search for the filename with that timestamp.

I don’t have a working example but I expect it would look something like this:

```robot
***Settings***
Library Browser
Library BuiltIn
Library OperatingSystem

***Tests***
Check Image Download
    ${imgurl} = Get Attribute #your_img href 
    ${timestamp} = Get Time epoch
    Download ${imgurl} saveAs=${OUTPUT DIR}/downloads/imagename_${timestamp}.png
    File Should Not Exist ${OUTPUT DIR}/downloads/imagename_${timestamp}.png

```

I just typed that example based on the docs so you may need to tweak it but it should be close to what you’re after.

Dave.

---

<div class="post-metadata">

**Author:** ![TorSte](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@TorSte](https://forum.robotframework.org/u/TorSte)\
**Post date:** [5 November 2026 13:36 UTC](https://forum.robotframework.org/t/how-do-you-check-that-a-browser-download-has-finished-before-opening-the-file/9893/3 "2026-11-05T13:36:22Z")

</div>

This is a workflow I am using:

```
${timestamp}= Get Current Date result_format=%Y%m%d_%H%M%S
VAR ${file_path} ${OUTPUT_DIR}/${TEST_NAME}/${timestamp}.jpg
${old_timeout} Set Browser Timeout timeout=191s
${dl_promise} Promise To Wait For Download saveAs=${file_path}
Click ${download_button}
TRY
    ${file_object} Wait For ${dl_promise}
EXCEPT
	Switch Page NEW
	Take Screenshot EMBED
END
Set Browser Timeout timeout=${old_timeout}
File Should Exist ${file_object}[saveAs] msg=Image not found: ${file_object}[saveAs]

```

This saves images in the output folder, there under a folder with the tests name and a timestamp as filename.  
Setting Browser timeout makes sure download has enough time to start and finish.  
If I get a timeout, those are shown in a separate tab, therfore “Switch Page” before taking a screenshot.  
Hope this helps.
