Skip to content

Commit 34d8180

Browse files
committed
Add wait condition to stabilize on slow machines
1 parent b91b2cd commit 34d8180

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

tests/downloads/test_mixed_content_download_via_https.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import re
2+
import time
23

34
import pytest
5+
from selenium.common.exceptions import StaleElementReferenceException
46
from selenium.webdriver import Firefox
57
from selenium.webdriver.common.by import By
68
from selenium.webdriver.support import expected_conditions as EC
@@ -20,6 +22,7 @@ def delete_files_regex_string():
2022

2123

2224
MIXED_CONTENT_DOWNLOAD_URL = "https://file-examples.com/wp-content/storage/2018/04/file_example_AVI_480_750kB.avi"
25+
TIMEOUT = 30
2326

2427

2528
def test_mixed_content_download_via_https(driver: Firefox, delete_files):
@@ -50,7 +53,17 @@ def test_mixed_content_download_via_https(driver: Firefox, delete_files):
5053
)
5154

5255
# Verify that the download progress has reached 100%, which indicates that the download is complete.
53-
download_status_value = download_status.get_attribute("value")
54-
assert download_status_value == "100", (
55-
f"The download status is not '100': {download_status_value}"
56-
)
56+
start_time = time.time()
57+
while True:
58+
try:
59+
download_value = download_status.get_attribute("value")
60+
if download_value == "100":
61+
break
62+
except StaleElementReferenceException:
63+
pass
64+
65+
if time.time() - start_time > TIMEOUT:
66+
raise TimeoutError(
67+
"Download progress did not reach 100% within the timeout."
68+
)
69+
time.sleep(1)

0 commit comments

Comments
 (0)