Appearance
UI.Downloads.hasFile()
Checks whether a file matching a given file name or pattern has been downloaded during the test.
Usage
js
UI.Downloads.hasFile(filename: string)
UI.Downloads.hasFile(filename: RegExp)Parameters
| Parameter | Type | Description |
|---|---|---|
filename | string | RegExp | Filename to match, or a regular expression pattern to match against downloaded filenames |
Returns
Returns true if at least one downloaded file matches the given filename or pattern. Otherwise, returns false.
Examples
Exact match
js
if (!UI.Downloads.hasFile("invoice.pdf")) {
TEST.log.fail("invoice.pdf was not downloaded")
}Match using regular expression
js
// match files like: invoice-2026-01-27.pdf
if (!UI.Downloads.hasFile(/^invoice-\d{4}-\d{2}-\d{2}\.pdf$/)) {
TEST.log.fail("Expected an invoice PDF to be downloaded")
}