Skip to main content
A union type representing different methods to trigger file downloads in web automation. This type standardizes how download operations can be initiated, providing multiple approaches for different automation scenarios. Type variants:
  • string: Direct URL string to download from
  • Locator: Playwright Locator object pointing to a clickable download element
  • (page: Page) => Promise<void>: Custom async function that takes a Page and triggers the download
export type Trigger = string | Locator | ((page: Page) => Promise<void>);

Examples

import { downloadFile } from "@intuned/browser";
import { BrowserContext, Page } from "playwright";

interface Params {}

export default async function handler(
  params: Params,
  page: Page,
  context: BrowserContext
) {
  // Direct download from URL
  const download = await downloadFile({
    page,
    trigger: "https://example.com/report.pdf",
  });
}