Skip to main content
Downloads a file from a web page using various trigger methods. This function provides three flexible ways to initiate file downloads:
  • URL: Creates a new page, navigates to the URL, waits for download, then automatically closes the page. Ideal for direct download links.
  • Locator: Uses the current page to click the element and capture the resulting download. Perfect for download buttons or interactive elements.
  • Callback: Executes the provided function with the page object and captures the first triggered download. Offers maximum flexibility for complex download scenarios.

Examples

Arguments

page
Page
required
The Playwright Page object to use for the download.
trigger
Trigger
required
The Trigger method to initiate the download.
timeout_s
int
Maximum time in seconds to wait for download to start. Defaults to 5.

Returns: Download

The Playwright Download object representing the downloaded file.