Wait For Download Finished

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
    client
        // Open DemoQA upload/donwload page
        .url('https://demoqa.com/upload-download')
        .waitForElementVisible('#app', 1000)

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

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