Skip to main content

Wait For Download Finished

client.waitForDownloadFinished(fileName: string, timeout = 1000: int);

This command waits until file download is completed or timeout is exceeded. This function is useful if download has to be completed before end of the test. Download completion check is done every 500 ms, so it can be used for crude download time measurement as well.

The fileName parameter specifies file name to wait for in downloads directory. This parameter can not be empty, otherwise an Error will be thrown.

The timeout parameter specifies time in ms, how long to wait for file download to be completed. If no timeout parameter is provided, default value 1000 ms is used. When timeout is exceeded an Error is thrown.

client => {
// Example of waiting for file to be downloaded
// Open DemoQA upload/donwload page
.waitForElementVisible('#app', 1000)

// Start download
.waitForElementVisible('#downloadButton', 10 * 1000)

// Wait for download to finish
.waitForDownloadFinished('sampleFile.jpeg', 5 * 60 * 1000)