File downloads
DrevOps\BehatSteps\Steps\Web\FileDownloadTrait - Source, Example, Helpers
Test file download functionality with content verification.
- Download files through links and URLs with session cookie handling.
- Verify file names, content, and zip archive entries.
- Set up download directories and handle file cleanup.
Skip processing with tag:
@behat-steps-skip:FileDownloadTrait.
Special tags:
@download- enable download handling
Options
| Option | Type | Default | Tag | Description |
|---|---|---|---|---|
file_download.enabled | boolean | TRUE | @behat-steps-skip:FileDownloadTrait | Prepare and clean up the download directory around a @download scenario. |
file_download.temp_dir | string | '/tmp/behat_downloads' | - | Directory a @download scenario writes downloaded files into. |
file_download.timeout | integer | 120 | - | How long, in seconds, a file download may wait for data. |
Steps
@When I download the file from the URL :url
Download a file from the specified URL
When I download the file from the URL "/files/document.pdf"
When I download the file from the URL "http://example.com/files/report.xlsx"
@When I download the file from the link :link
Download the file from the specified HTML link
When I download the file from the link "Download PDF"
When I download the file from the link "Get Report"
@Then the downloaded file should contain:
Assert the contents of the download file
Then the downloaded file should contain:
"""
Financial Report 2023
"""
@Then the downloaded file name should be :name
Assert the file name of the downloaded file
Then the downloaded file name should be "report.pdf"
@Then the downloaded file name should contain :partial_name
Assert the downloaded file name contains a specific string
Then the downloaded file name should contain "report"
@Then the downloaded file should be a zip archive containing files with the following names:
Assert the downloaded file should be a zip archive containing specific files
Then the downloaded file should be a zip archive containing files with the following names:
| document.pdf |
| image.jpg |
| data.csv |
@Then the downloaded file should be a zip archive containing files with the following partial names:
Assert the downloaded file should be a zip archive containing files with partial names
Then the downloaded file should be a zip archive containing files with the following partial names:
| report |
| data |
| image |
@Then the downloaded file should be a zip archive not containing files with the following partial names:
Assert the downloaded file is a zip archive not containing files with partial names
Then the downloaded file should be a zip archive not containing files with the following partial names:
| confidential |
| private |
| draft |