Appearance
UI.Downloads.files
A read-only property that lists information about files downloaded during the test.
Usage
js
var files = UI.Downloads.files
// alternatively, you can also use listFiles()
var files = UI.Downloads.listFiles()Returns
Returns an array of objects, where each object represents a downloaded file.
Each file object contains the following properties:
| Property | Type | Description |
|---|---|---|
name | string | Name of the downloaded file |
path | string | Path where file is stored in the virtual directory. |
lastModified | number | Time the file was created, in epoch seconds. |
size | number | File size in bytes |
Example return value:
js
[
{
"name": "file1.pdf",
"path": "//downloads/file1.pdf",
"lastModified": 1678863067,
"size": 2142210
},
{
"name": "file2.pdf",
"path": "//downloads/file2.pdf",
"lastModified": 1678863088,
"size": 3058254
}
]Files appear in the array in the order they were downloaded.
The array includes .first and .last convenience getters, which return the metadata for the first and last downloaded files.
Examples
Validate number of downloaded files
js
if (UI.Downloads.files.length === 0) {
TEST.log.fail("Expected a file to be downloaded, but none were found")
}In the example, the test checks the number of downloaded files and fails the test if there are no files downloaded.
Validate file size
js
var file = UI.Downloads.files.last
if (file && file.size > 0) {
TEST.log.pass("File downloaded successfully")
} else {
TEST.log.fail("File downloaded failed.")
}In the example above, the test checks the size of the last downloaded file and fails the test if the file is missing or has a size of zero.