From 2299f0e5d8aa51e3530257828e62cd8e8fbd89a6 Mon Sep 17 00:00:00 2001 From: "virgil.sangerean" Date: Fri, 3 Oct 2025 16:54:24 +0300 Subject: [PATCH] vs/try to fix --- tests/preferences/test_clear_cookie_data.py | 46 ++++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/tests/preferences/test_clear_cookie_data.py b/tests/preferences/test_clear_cookie_data.py index 512f2beef..2390e8e8d 100644 --- a/tests/preferences/test_clear_cookie_data.py +++ b/tests/preferences/test_clear_cookie_data.py @@ -3,6 +3,7 @@ import pytest from selenium.webdriver import Firefox +from selenium.webdriver.support.ui import WebDriverWait from modules.page_object import AboutPrefs from modules.util import BrowserActions @@ -17,33 +18,46 @@ def test_case(): def open_clear_cookies_data_dialog(about_prefs: AboutPrefs, ba: BrowserActions): + """ + Open about:preferences#privacy, show 'Clear Data' dialog, switch into its iframe, + read 'Cookies and site data' value, then switch back to content context. + """ about_prefs.open() - clear_data_popup = about_prefs.press_button_get_popup_dialog_iframe("Clear Data") - ba.switch_to_iframe_context(clear_data_popup) - return about_prefs.get_clear_cookie_data_value() - + iframe = about_prefs.press_button_get_popup_dialog_iframe("Clear Data") + ba.switch_to_iframe_context(iframe) + value = about_prefs.get_clear_cookie_data_value() + ba.switch_to_content_context() + return value -@pytest.mark.skipif(WIN_GHA, reason="Test unstable in Windows GA, tracked in 1990570") +#@pytest.mark.skipif(WIN_GHA, reason="Test unstable in Windows GA, tracked in 1990570") def test_clear_cookie_data(driver: Firefox): """ - C143627: Cookies and site data can be cleared via the "Clear Data" panel + C143627: Cookies and site data can be cleared via the 'Clear Data' panel """ - # Instantiate objects about_prefs = AboutPrefs(driver, category="privacy") ba = BrowserActions(driver) + wait = WebDriverWait(driver, 20) - # Visit a site to get a cookie added to saved data + # 1) Visit a site so Firefox stores site data/cookies driver.get("https://www.wikipedia.com") - # Navigate to the clear data dialog of about:preferences#privacy - # Check for a non-zero value of the 'Cookies and site data' option - cookie_value = open_clear_cookies_data_dialog(about_prefs, ba) - assert cookie_value > 0 + # 2) There should be something to clear (> 0) + initial = open_clear_cookies_data_dialog(about_prefs, ba) + assert initial > 0, f"Expected cookie/site data > 0 before clearing, got {initial}" - # Then clear the cookies and site data + # 3) Clear the data: open dialog, click 'Clear', then switch back to content + about_prefs.open() + iframe = about_prefs.press_button_get_popup_dialog_iframe("Clear Data") + ba.switch_to_iframe_context(iframe) about_prefs.get_element("clear-data-accept-button").click() + ba.switch_to_content_context() + + # 4) Re-open the dialog and wait until value becomes 0 + def cleared(_): + return open_clear_cookies_data_dialog(about_prefs, ba) == 0 - # Finally, check the value of the dialog option, it should be 0 + wait.until(cleared) - cookie_value2 = open_clear_cookies_data_dialog(about_prefs, ba) - assert cookie_value2 == 0 + # 5) Final explicit check + final = open_clear_cookies_data_dialog(about_prefs, ba) + assert final == 0, f"Expected 0 after clearing, got {final}"