Download

Playwright\Download\DownloadInterface

DownloadInterface for Playwright PHP.

Methods

cancel()

void

Cancels a download. Will not fail if the download is already finished or canceled. Upon successful cancellations, download.failure() would resolve to 'canceled'.

function cancel(): void

createReadStream()

Returns a readable stream for a successful download, or null if the transport does not provide it.

function createReadStream()

delete()

void

Deletes the downloaded file. Will wait for the download to finish if necessary.

function delete(): void

failure()

?string

Returns download error if any. Will wait for the download to finish if necessary.

function failure(): ?string

page()

PageInterface

Get the page that the download belongs to.

function page(): PageInterface

path()

?string

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.

function path(): ?string

saveAs()

void

Copy the download to a user-specified path. It is safe to call this method while the download is still in progress. Will wait for the download to finish if necessary.

function saveAs(string $path): void

suggestedFilename()

string

Returns suggested filename for this download. It is typically computed by the browser from the Content-Disposition response header or the download attribute.

function suggestedFilename(): string

url()

string
function url(): string