33
44import pytest
55from selenium .webdriver import Firefox
6+ from selenium .webdriver .support .ui import WebDriverWait
67
78from modules .page_object import AboutPrefs
89from modules .util import BrowserActions
@@ -17,33 +18,46 @@ def test_case():
1718
1819
1920def open_clear_cookies_data_dialog (about_prefs : AboutPrefs , ba : BrowserActions ):
21+ """
22+ Open about:preferences#privacy, show 'Clear Data' dialog, switch into its iframe,
23+ read 'Cookies and site data' value, then switch back to content context.
24+ """
2025 about_prefs .open ()
21- clear_data_popup = about_prefs .press_button_get_popup_dialog_iframe ("Clear Data" )
22- ba .switch_to_iframe_context (clear_data_popup )
23- return about_prefs .get_clear_cookie_data_value ()
24-
26+ iframe = about_prefs .press_button_get_popup_dialog_iframe ("Clear Data" )
27+ ba .switch_to_iframe_context (iframe )
28+ value = about_prefs .get_clear_cookie_data_value ()
29+ ba .switch_to_content_context ()
30+ return value
2531
26- @pytest .mark .skipif (WIN_GHA , reason = "Test unstable in Windows GA, tracked in 1990570" )
32+ # @pytest.mark.skipif(WIN_GHA, reason="Test unstable in Windows GA, tracked in 1990570")
2733def test_clear_cookie_data (driver : Firefox ):
2834 """
29- C143627: Cookies and site data can be cleared via the " Clear Data" panel
35+ C143627: Cookies and site data can be cleared via the ' Clear Data' panel
3036 """
31- # Instantiate objects
3237 about_prefs = AboutPrefs (driver , category = "privacy" )
3338 ba = BrowserActions (driver )
39+ wait = WebDriverWait (driver , 20 )
3440
35- # Visit a site to get a cookie added to saved data
41+ # 1) Visit a site so Firefox stores site data/cookies
3642 driver .get ("https://www.wikipedia.com" )
3743
38- # Navigate to the clear data dialog of about:preferences#privacy
39- # Check for a non-zero value of the 'Cookies and site data' option
40- cookie_value = open_clear_cookies_data_dialog (about_prefs , ba )
41- assert cookie_value > 0
44+ # 2) There should be something to clear (> 0)
45+ initial = open_clear_cookies_data_dialog (about_prefs , ba )
46+ assert initial > 0 , f"Expected cookie/site data > 0 before clearing, got { initial } "
4247
43- # Then clear the cookies and site data
48+ # 3) Clear the data: open dialog, click 'Clear', then switch back to content
49+ about_prefs .open ()
50+ iframe = about_prefs .press_button_get_popup_dialog_iframe ("Clear Data" )
51+ ba .switch_to_iframe_context (iframe )
4452 about_prefs .get_element ("clear-data-accept-button" ).click ()
53+ ba .switch_to_content_context ()
54+
55+ # 4) Re-open the dialog and wait until value becomes 0
56+ def cleared (_ ):
57+ return open_clear_cookies_data_dialog (about_prefs , ba ) == 0
4558
46- # Finally, check the value of the dialog option, it should be 0
59+ wait . until ( cleared )
4760
48- cookie_value2 = open_clear_cookies_data_dialog (about_prefs , ba )
49- assert cookie_value2 == 0
61+ # 5) Final explicit check
62+ final = open_clear_cookies_data_dialog (about_prefs , ba )
63+ assert final == 0 , f"Expected 0 after clearing, got { final } "
0 commit comments