Skip to content

browser.wait.until.download_file#

Functions#

does_not_exist(file_name, timeout=None) #

Wait until a file download does not exist, e.g. a temporary file created by the browser until download is complete.

Parameters:

Name Type Description Default
file_name str

Name of the file to watch in the download directory, e.g. file.zip. The download directory is implicitly defined in the download_dir parameter of BrowserSettings.

required
timeout float | None

In seconds. Timeout to wait for file to not exist. If None, the global timeout setting is used (default 5 seconds).

None
Example
1
2
3
4
5
6
from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")
    browser.click.download("//xpath/to/button", expected_file_name="file.zip"))
    browser.wait.until.download_file.does_not_exist("file.zip.download")

exists(file_name, timeout=None) #

Wait until a file download exists.

Parameters:

Name Type Description Default
file_name str

Name of the file to watch in the download directory, e.g. file.zip. The download directory is implicitly defined in the download_dir parameter of BrowserSettings.

required
timeout float | None

In seconds. Timeout to wait for file to exist. If None, the global timeout setting is used (default 5 seconds).

None
Example
1
2
3
4
5
6
from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")
    browser.click.download("//xpath/to/button", expected_file_name="file.zip"))
    browser.wait.until.download_file.exists("file.zip")

size_does_not_increase(file_name, idle_download_timeout=None) #

Wait until a file under download no longer exists or increases in size, for example a temporary file created by the browser until a download is complete.

Parameters:

Name Type Description Default
file_name str

Name of the file to watch in the download directory, e.g. file.zip. The download directory is implicitly defined in the download_dir parameter of BrowserSettings.

required
idle_download_timeout float | None

In seconds. Timeout to wait for file size to not increase, which is constantly renewed as long as the file size increases. If None, the global idle download timeout setting is used (default 3 seconds).

None
Example
1
2
3
4
5
6
from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")
    browser.click.download("//xpath/to/button", expected_file_name="file.zip"))
    browser.wait.until.download_file.size_does_not_increase("file.zip")