Intercept file downloads triggered by clicking DOM elements.
downloadViaClick captures the file contents as a buffer so your workflow can process the file directly without relying on browser rendering behavior.downloadViaClick()12345async function downloadViaClick( page: Page, selector: string, options?: DownloadViaClickOptions, ): Promise<DownloadResult>;
path pagePagerequiredPage to operate on.path selectorstringrequiredpath optionsDownloadViaClickOptionspath loggerMinimalLoggerpath timeoutnumber30000.DownloadResultbufferBufferfilenamestringContent-Disposition header or
the URL.12345678import { downloadViaClick } from "libretto"; const { buffer, filename } = await downloadViaClick(page, "#export-btn", { logger, timeout: 60_000, }); console.log(`Downloaded ${filename} (${buffer.length} bytes)`);