Download File
Download File
Section titled “Download File”Type: page-download-file · Package: Browser v1.0.9 · Output: string
Downloads a file when you already have its link: you got it from a table, from a button’s href or from another page. It doesn’t click anything; it requests the file directly and saves it to disk, returning the full path.
The download uses the same browser session: it shares its cookies and signed-in state. That’s why it works with files that can only be downloaded after signing in to the portal, where a plain HTTP request would get the login page instead of the file.
How it works
Section titled “How it works”- If the
urlis relative (/reports/2026.pdf), it completes it with the address of the current page. - It requests the file (GET) with the browser session’s cookies, up to
timeout. - If the server answers with a non-success code (outside 200-299), it fails with that code.
- It saves it to
outputPathand returns the full path of the saved file.
If outputPath is a folder, the file name is the one the server gives (Content-Disposition header, preferring filename*, which supports accented characters) or, if it gives none, the last segment of the URL. If no usable name exists, it is saved as download. The name is stripped of paths and invalid characters, so it never writes outside the given folder.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
url | string | — | URL of the file to download. Relative URLs are completed with the current page’s URL. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
page | ZoanPageSession | — | The page session. Inside the body of Open Browser or Attach Browser it is inherited automatically. |
outputPath | string | temp folder | Folder or file path to save to. If you give a folder, the name comes from the server or the URL. Empty: the system temp folder. |
timeout | number | 30000 | Maximum time in ms for the request. 0 or negative: the default. It doesn’t use the project timeout. |
Output
Section titled “Output”Returns a string with the full path of the saved file, e.g. C:\Downloads\reports\report-2026-09.xlsx.
Example
Section titled “Example”Read the link of a report and download it to a folder:
Open Browser browser = chrome url = "https://portal.example.com/reports" └─ body: Page Get Attribute selector = (#reporteMensual) attribute = "href" → output: enlace Download File url = enlace outputPath = "C:\Downloads\reports" → output: rutaReporte Excel Open path = rutaReporte → output: libroSave with a name of your choice:
Download File page = page url = "/invoices/INV-1042.pdf" outputPath = "C:\Invoices\INV-1042.pdf"Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'url' is required. | url is empty. Check the variable the link comes from. |
'url' is not a valid URL and could not be resolved against the current page. | The URL isn’t valid and couldn’t be completed with the current page’s URL. |
The server answered HTTP 404 Not Found. | The server didn’t find the file. Check the URL. |
The server answered HTTP 401 … / 403 … | The session has no permission: the sign-in expired or that account can’t see the file. Sign in again before downloading. |
Timeout 30000ms exceeded | The server took longer than timeout to deliver the file. Raise it for large files or slow servers. |
'page' must be a ZoanPageSession. | page is empty outside a body. |
Related activities
Section titled “Related activities”- Wait for Download — when the download is triggered by a click.
- Get Attribute — read a link’s
href. - Excel Open / Read File — process the downloaded file.