Skip to main content
async def download_file(
    page: Page,
    trigger: Trigger,
    *,
    timeout_s: int = 5,
) -> Download
Downloads a file from a web page using various trigger methods. This function provides three flexible ways to initiate file downloads:
  1. URL Navigation: Directly navigate to a URL that triggers a download
  2. Element Interaction: Click on a Playwright Locator (e.g., download button or link)
  3. Custom Callback: Execute a custom function to trigger the download programmatically
Trigger Behavior
  • URL
  • Locator
  • Callback
Creates a new page, navigates to the URL, waits for download, then automatically closes the page. Ideal for direct download links.

Examples

from intuned_browser import download_file
async def automation(page, params, **_kwargs):
    download = await download_file(page, 'https://intuned-docs-public-images.s3.amazonaws.com/32UP83A_ENG_US.pdf')

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
default:"5"
Maximum time in seconds to wait for download completion. Defaults to 5.

Returns: Download

The Playwright Download object representing the downloaded file.