Skip to main content
export declare function downloadFile(input: {
  page: Page;
  trigger: Trigger;
  timeoutInMs?: number;
}): Promise<Download>;
Downloads a file from a web page using various trigger methods. This function provides three flexible ways to initiate file downloads:
  1. URL Navigation: Directly navigate to a URL that triggers a download
  2. Element Interaction: Click on a Playwright locator (e.g., download button or link)
  3. Custom Callback: Execute a custom function to trigger the download programmatically
Trigger Behavior
  • URL
  • Locator
  • Callback
Creates a new page, navigates to the URL, waits for download, then automatically closes the page. Ideal for direct download links.

Examples

import { downloadFile } from "@intuned/browser";
export default async function handler(params, page, context){
// Download by navigating directly to a URL
const download = await downloadFile({
  page,
  trigger: "https://intuned-docs-public-images.s3.amazonaws.com/32UP83A_ENG_US.pdf"
});
console.log(`Downloaded to: ${await download.path()}`);
}

Arguments

input
Object
required
Configuration object for the download operation

Returns: Promise<Download>

Promise that resolves to a Playwright Download object