Skip to content

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.

  1. If the url is relative (/reports/2026.pdf), it completes it with the address of the current page.
  2. It requests the file (GET) with the browser session’s cookies, up to timeout.
  3. If the server answers with a non-success code (outside 200-299), it fails with that code.
  4. It saves it to outputPath and 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.

ParameterTypeDefaultDescription
urlstring—URL of the file to download. Relative URLs are completed with the current page’s URL.
ParameterTypeDefaultDescription
pageZoanPageSession—The page session. Inside the body of Open Browser or Attach Browser it is inherited automatically.
outputPathstringtemp folderFolder 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.
timeoutnumber30000Maximum time in ms for the request. 0 or negative: the default. It doesn’t use the project timeout.

Returns a string with the full path of the saved file, e.g. C:\Downloads\reports\report-2026-09.xlsx.

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: libro

Save with a name of your choice:

Download File page = page url = "/invoices/INV-1042.pdf" outputPath = "C:\Invoices\INV-1042.pdf"
MessageCause 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 exceededThe 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.