Playwright icon

Playwright

Automate browser actions using Playwright

Download File

AI-generated

Summary

Downloads a file in the current remote Playwright browser session, either by clicking a page element and capturing the resulting file or by fetching a direct URL, and stores it as binary data on the output item.

Inputs

  • Download Source — 'Element' (default) clicks a page element and captures the download; 'URL' fetches a file directly.
  • Selector Type — CSS or XPath. Element source only.
  • CSS Selector / XPath (required) — Selector of the element to click (first match is used). Element source only; which field applies depends on Selector Type.
  • Download URL (required) — Direct file URL. URL source only. Relative URLs resolve against the current page. Only http/https are allowed by default (extra protocols via N8N_PLAYWRIGHT_NODE_PROTOCOLS).
  • File Name — Optional file name fallback for URL source. A Content-Disposition filename takes precedence; otherwise the name is taken from the URL.
  • Download Property Name (required) — Binary property that receives the file (default 'data').
  • Download Options — Element source only: Click Timeout (15000 ms), Wait Timeout for download/popup/navigation (15000 ms), Prefer Popup Page (default true).
  • Browser — Firefox (default) or Chromium, used when connecting to the remote browser.
  • Leave Session Open — Keep the browser session open for following Playwright nodes (default true). If off, the session is closed after the download.
  • Browser Endpoint — Remote Playwright WebSocket endpoint. If empty, it is inherited from the existing session or the previous Playwright node. An error is thrown if none is found.
  • Browser Connection Options — Connection Timeout (30000 ms), Ignore SSL Issues, and Session ID. Set Session ID manually if the previous node is not a Playwright node.

Output shape

One item per input item, with the file in binary. and JSON metadata: success, method (how the file was captured), fileName, mimeType, size, url/pageUrl, status where applicable, plus a playwright object with sessionKey and browserEndpoint.

URL source tries three methods in order: fetch inside the page (with cookies), the Playwright request API, then a Node fetch with the page's cookies. Element source JSON also includes selectorType and selector. Element mode first tries the download event, then href fetching, then response capture and popup handling. It may also include navigated and popupOpened flags. Empty files, or no downloadable file after the click, raise an error. With Continue On Fail, the item instead contains error and playwright.sessionKey.

Examples

Example 1: Download a PDF invoice by clicking a link after logging in

Download Source=Element, Selector Type=CSS, Selector=a.download-invoice, Download Property Name=invoice, Leave Session Open=true (reuse the session from earlier Fill Form/Navigate nodes).

Example 2: Fetch a known file URL using the logged-in session's cookies

Download Source=URL, Download URL=https://example.com/reports/report.pdf, File Name=report.pdf, Download Property Name=data.

Example 3: Download from a slow button that opens a popup

Download Source=Element, Selector Type=XPath, XPath=//button[text()="Export"], Download Options: Wait Timeout=45000, Prefer Popup Page=true.

Links

Discussion