Skip to main content

Recipe

This recipe shows how to download files triggered by a button click or link with downloadFile (TypeScript) or download_file (Python).
TypeScript
import { BrowserContext, Page } from "playwright";
import { downloadFile } from "@intuned/browser"

interface Params {
  // Add your params here
}

export default async function handler(
  params: Params,
  page: Page,
  context: BrowserContext
) {
  await page.goto("https://sandbox.intuned.dev/pdfs")

  // Locate the download button
  const downloadLocator = page.locator("xpath=//tbody/tr[1]//*[name()='svg']")

  // Trigger download and wait for file
  const downloadedFile = await downloadFile({
    page,
    trigger: downloadLocator,
    timeoutInMs: 15000,
  })

  const fileName = downloadedFile.suggestedFilename()
  return fileName
}

downloadFile (TypeScript)

TypeScript SDK helper for downloading files

download_file (Python)

Python SDK helper for downloading files

saveFileToS3 (TypeScript)

TypeScript SDK helper for saving files to S3

save_file_to_s3 (Python)

Python SDK helper for saving files to S3