Skip to content

Wait for Download

Type: page-wait-for-download  ·  Package: Browser v1.0.9  ·  Output: string

Downloads a file from the page reliably. You wrap inside its body the action that triggers the download (a click on “Download”, a PDF/Excel export link) and the activity waits for the download to finish, returning the full path of the saved file.

It solves a classic problem: if you just click “Download” and move on, the file may not have finished downloading when the next activity tries to open it. This activity synchronizes both.

  1. It starts “listening” for downloads on the session tab.
  2. It runs the activities in the body (which trigger the download).
  3. It waits for the download to start, up to timeout; then it waits for it to finish, with no time limit.
  4. It saves it to outputPath and returns the full path of the saved file.
  • If outputPath is a folder, the file is named as the site suggests (the name you would see in the browser). It’s treated as a folder if it already exists as a folder, if it ends in \ or /, or if it has no extension; otherwise, as a file path.
  • Missing folders are created automatically and a file with the same name is overwritten.
  • It only listens on the session tab: if the download comes from another tab (a pop-up window), pass that tab’s session.
  • The activities in the body do not inherit session: they use the page of the Open Browser body that contains them, or the one you pass in page.
ParameterTypeDefaultDescription
sessionZoanPageSession—The session of the tab where the download happens. Pass page; it isn’t inherited from the body.
ParameterTypeDefaultDescription
outputPathstringtemp folderFolder or file path to save to. If you give a folder, the name suggested by the site is used. Empty: the system temp folder.
timeoutnumber30000Maximum time in ms to wait for the download to start. 0 or negative: the default. It doesn’t use the project timeout.

Optional. The activities that trigger the download (a click on the download button, an export link). If you leave it empty, the activity just waits for a download that starts some other way.

Returns a string with the full path of the downloaded file, e.g. C:\Downloads\reports\sales.xlsx.

Export a report to Excel and get its path to process it:

Wait for Download session = page outputPath = "C:\Downloads\reports" → output: rutaReporte
└─ body:
Page Click page = page selector = (#exportarExcel)
Excel Open path = rutaReporte → output: libro
MessageCause and fix
'session' must be a ZoanPageSession.session is empty or doesn’t hold a page session. Pass page (even if you’re inside a body).
Timeout 30000ms exceeded … waiting for the downloadNo download started in time: the click didn’t trigger it, it opened in another tab or the site displayed it in the browser. Check the body action, raise timeout or use Download File if you have the URL.
Error saving the fileThe path doesn’t allow writing or the file is open in another program (e.g. Excel). Close it or use another path.