class Playwright::Download
“‘
download.save_as(“/path/to/save/at/” + download.suggested_filename)
# Wait for the download process to complete and save the downloaded file somewhere
download = download_info.value
page.get_by_text(“Download file”).click()
# Perform the action that initiates download
with page.expect_download() as download_info:
# Start waiting for the download
“`python sync
Download event is emitted once the download starts. Download path becomes available once download completes.
browser context is closed.
All the downloaded files belonging to the browser context are deleted when the
`Download` objects are dispatched by page via the [`event: Page.download`] event.
def cancel
Cancels a download. Will not fail if the download is already finished or canceled.
def cancel wrap_impl(@impl.cancel) end
def delete
def delete wrap_impl(@impl.delete) end
def failure
def failure wrap_impl(@impl.failure) end
def page
def page wrap_impl(@impl.page) end
def path
Note that the download's file name is a random GUID, use [`method: Download.suggestedFilename`]
Returns path to the downloaded file for a successful download, or throws for a failed/canceled download. The method will wait for the download to finish if necessary. The method throws when connected remotely.
def path wrap_impl(@impl.path) end
def save_as(path)
download.save_as("/path/to/save/at/" + download.suggested_filename)
```python sync
**Usage**
is still in progress. Will wait for the download to finish if necessary.
Copy the download to a user-specified path. It is safe to call this method while the download
def save_as(path) wrap_impl(@impl.save_as(unwrap_impl(path))) end
def suggested_filename
or the `download` attribute. See the spec on [whatwg](https://html.spec.whatwg.org/#downloading-resources). Different
[`Content-Disposition`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) response header
Returns suggested filename for this download. It is typically computed by the browser from the
def suggested_filename wrap_impl(@impl.suggested_filename) end
def url
def url wrap_impl(@impl.url) end