Wait For Download Finished #
def wait_for_download_finished( driver: TestUIDriver, file_name: str, timeout: int = 1000 ) -> None
This command waits until file download is completed or timeout is exceeded. This function is useful if download has to be completed before the end of the test. Download completion check is done every 500 ms, so it can be used for crude download time measurement as well.
file_name parameter specifies file name to wait for in downloads directory.
This parameter can not be
None or empty, otherwise an Error will be thrown.
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 the function will raise an Py-TestUI error but
test execution will continue.
def test(driver): driver.navigate_to("https://www.thinkbroadband.com/download") e(driver, "css", "div#main").wait_until_visible(seconds=10) e(driver, "css", "a[href^=\"http://ipv4.download.thinkbroadband.com/50MB.zip\"] img"). wait_until_visible(seconds=10). click() start = datetime.now() wait_for_download_finished(driver, "50MB.zip", 30 * 1000) print("Download time: ", datetime.now() - start)