Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions modules/page_object_about_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from selenium.webdriver import Firefox
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait

from modules.page_base import BasePage
from modules.page_object_generics import GenericPage
Expand Down Expand Up @@ -194,10 +195,33 @@ def remove_password_csv(self, downloads_dir):
if delete_files_regex.match(file):
os.remove(passwords_csv)

def verify_csv_export(self, downloads_folder: str, filename: str):
"""Wait until the exported CSV file is present in the target folder."""
def verify_csv_export(self, downloads_folder: str, filename: str, timeout: int = 20):
"""
Wait until the exported CSV file is present, non-empty, and readable.
"""
csv_file = os.path.join(downloads_folder, filename)
self.wait.until(lambda _: os.path.exists(csv_file))

def file_ready(_):
# Check if the file path exists. If not, continue
if not os.path.exists(csv_file):
return False
try:
# Verify that the file isn't empty
if os.path.getsize(csv_file) == 0:
return False

# Attempt to read a few bytes to ensure the file is unlocked
# and readable (handles cases where the OS is still writing).
with open(csv_file, "r", encoding="utf-8") as f:
f.read(10)
return True

except (OSError, PermissionError) as e:
# Log and retry until timeout instead of failing immediately
logging.debug(f"[verify_csv_export] File not ready yet: {e}")
return False

WebDriverWait(self.driver, timeout).until(file_ready)
return csv_file

def add_login(self, origin: str, username: str, password: str):
Expand Down
1 change: 0 additions & 1 deletion tests/password_manager/test_password_csv_correctness.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def test_case():
return "2241522"


@pytest.mark.unstable(reason="Bug 1996004")
@pytest.mark.headed
@pytest.mark.noxvfb
def test_password_csv_correctness(
Expand Down
1 change: 0 additions & 1 deletion tests/password_manager/test_password_csv_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def test_case():
return "2241521"


@pytest.mark.unstable(reason="Bug 1996005")
@pytest.mark.headed
@pytest.mark.noxvfb
def test_password_csv_export(
Expand Down