Browser

File Downloads, Uploads, and Export

Methods for downloading files by clicking links, uploading files through file inputs, printing pages to PDF, and exporting scraped data to CSV, Excel, or text files.

Methods for downloading files by clicking links, uploading files through file inputs, printing pages to PDF, and exporting scraped data to CSV, Excel, or text files.

LeftClickAndDownload clicks an element and waits for the browser to download the file, saving it to the specified GPALFile path. RightClickAndDownload right-clicks and uses 'Save As'. LeftClickAndUpload clicks a file input element and uploads the specified file. PrintToPDF saves the current page as a PDF. SaveToCSV, SaveToExcel, SaveToFile, and SaveToTabbedText export the data collected by the current selector. The Append variants add to an existing file rather than overwriting.

TIP

Configure download behavior with WithDownloadLocation (directory), WithDownloadTimeoutInSec (wait time), and WithOverwriteExistingFile (true to overwrite, false to auto-rename). These are typically set during browser setup before the first navigation.

WARNING

LeftClickAndDownload, LeftClickAndUpload, RightClickAndDownload, PrintToPDF, and the SaveTo* export methods only have a GPALFile overload - there is no separate string overload to compete with it. Because GPALFile has an implicit conversion from string, a plain path string can be passed directly, e.g. .LeftClickAndDownload("C:\Downloads\report.pdf"). GPAL.FileFor(...) is equivalent and mainly useful when you want to build and reuse a GPALFile reference across multiple calls.

Examples

GPAL Fluent: High-level fluent C# API

//LeftClickAndDownload waits for the file to appear in the download directory before returning. Use WithDownloadTimeoutInSec to extend the wait for large files.

// Download a file by clicking a link GPAL.Browser .GoTo("https://example.com/reports") .WithSelector(".download-link") .LeftClickAndDownload("C:\Downloads\report.pdf"); // Upload a file GPAL.Browser .WithSelector("#file-input") .LeftClickAndUpload("C:\data\import.csv"); // Export scraped table data to CSV GPAL.Browser .GoTo("https://example.com/data") .WithSelector(".row") .WithAllThatMatch(1000) .SaveToCSV("scraped.csv");