Class: Playwright::Download
- Inherits:
-
PlaywrightApi
- Object
- PlaywrightApi
- Playwright::Download
- Defined in:
- lib/playwright_api/download.rb
Overview
‘Download` objects are dispatched by page via the [`event: Page.download`] event.
All the downloaded files belonging to the browser context are deleted when the browser context is closed. All downloaded files are deleted when the browser closes.
Download event is emitted once the download starts. Download path becomes available once download completes:
“‘js const [ download ] = await Promise.all([
page.waitForEvent('download'), // wait for download to start
page.click('a')
]); // wait for download to complete const path = await download.path(); … “‘
> NOTE Browser context must be created with the ‘acceptDownloads` set to `true` when user needs access to the downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual download is not performed and user has no access to the downloaded files.
Instance Method Summary collapse
-
#create_read_stream ⇒ Object
Returns readable stream for current download or ‘null` if download failed.
-
#delete ⇒ Object
Deletes the downloaded file.
-
#failure ⇒ Object
Returns download error if any.
-
#path ⇒ Object
Returns path to the downloaded file in case of successful download.
-
#save_as(path) ⇒ Object
Saves the download to a user-specified path.
-
#suggested_filename ⇒ Object
Returns suggested filename for this download.
-
#url ⇒ Object
Returns downloaded url.
Methods inherited from PlaywrightApi
Instance Method Details
#create_read_stream ⇒ Object
Returns readable stream for current download or ‘null` if download failed.
26 27 28 |
# File 'lib/playwright_api/download.rb', line 26 def create_read_stream raise NotImplementedError.new('create_read_stream is not implemented yet.') end |
#delete ⇒ Object
Deletes the downloaded file.
31 32 33 |
# File 'lib/playwright_api/download.rb', line 31 def delete raise NotImplementedError.new('delete is not implemented yet.') end |
#failure ⇒ Object
Returns download error if any.
36 37 38 |
# File 'lib/playwright_api/download.rb', line 36 def failure raise NotImplementedError.new('failure is not implemented yet.') end |
#path ⇒ Object
Returns path to the downloaded file in case of successful download.
41 42 43 |
# File 'lib/playwright_api/download.rb', line 41 def path raise NotImplementedError.new('path is not implemented yet.') end |
#save_as(path) ⇒ Object
Saves the download to a user-specified path.
46 47 48 |
# File 'lib/playwright_api/download.rb', line 46 def save_as(path) raise NotImplementedError.new('save_as is not implemented yet.') end |
#suggested_filename ⇒ Object
Returns suggested filename for this download. It is typically computed by the browser from the [‘Content-Disposition`](developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) response header or the `download` attribute. See the spec on [whatwg](html.spec.whatwg.org/#downloading-resources). Different browsers can use different logic for computing it.
54 55 56 |
# File 'lib/playwright_api/download.rb', line 54 def suggested_filename raise NotImplementedError.new('suggested_filename is not implemented yet.') end |
#url ⇒ Object
Returns downloaded url.
59 60 61 |
# File 'lib/playwright_api/download.rb', line 59 def url raise NotImplementedError.new('url is not implemented yet.') end |