1- from platform import system
2-
31import pytest
42from selenium .webdriver import Firefox
53from selenium .webdriver .support .ui import WebDriverWait
@@ -16,49 +14,29 @@ def test_case():
1614WEBSITE_ADDRESS = "https://www.wikipedia.com"
1715# WIN_GHA = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith("win")
1816
19-
20- def _dialog_options_present (about_prefs : AboutPrefs ) -> bool :
21- """Return True when the Clear Data dialog options container exists."""
22- try :
23- about_prefs .get_element ("clear-data-dialog-options" )
24- return True
25- except Exception :
26- return False
27-
28-
2917def _open_clear_cookies_data_dialog (
30- about_prefs : AboutPrefs , ba : BrowserActions , wait : WebDriverWait
18+ about_prefs : AboutPrefs , ba : BrowserActions
3119):
3220 """
33- Open about:preferences#privacy, show 'Clear Data' dialog, switch into its iframe,
34- wait for its options container to be present, read the value, then switch back.
21+ Open about:preferences#privacy, show the 'Clear Data' dialog, switch into its iframe,
22+ wait for its option container to be present, read the value, then switch back.
3523 """
3624 about_prefs .open ()
3725
3826 # Click the button and grab the dialog iframe element
39- dlg_iframe = about_prefs .press_button_get_popup_dialog_iframe ("Clear Data" )
40-
41- # Wait until the iframe is attached and visible before switching
42- wait .until (lambda _ : dlg_iframe and dlg_iframe .is_displayed ())
27+ dlg_iframe = about_prefs .clear_cookies_and_get_dialog_iframe ()
4328
4429 # Enter dialog iframe
4530 ba .switch_to_iframe_context (dlg_iframe )
4631
47- # Wait for dialog content to be ready (no custom timeout kwarg)
48- wait .until (lambda _ : _dialog_options_present (about_prefs ))
49-
5032 value = about_prefs .get_clear_cookie_data_value ()
5133
52- # Always return to content context
34+ # Always return to the content context
5335 ba .switch_to_content_context ()
36+ about_prefs .close_dialog_box ()
5437 return value
5538
5639
57- # @pytest.mark.skipif(WIN_GHA, reason="Test unstable in Windows GA, tracked in 1990570")
58- @pytest .mark .skipif (
59- system ().lower ().startswith ("darwin" ) or system ().lower ().startswith ("linux" ),
60- reason = "bug 1994055" ,
61- )
6240def test_clear_cookie_data (driver : Firefox ):
6341 """
6442 C143627: Cookies and site data can be cleared via the "Clear Data" panel
@@ -71,19 +49,19 @@ def test_clear_cookie_data(driver: Firefox):
7149 driver .get (WEBSITE_ADDRESS )
7250
7351 # Open dialog and read current value (must be > 0)
74- cookie_value = _open_clear_cookies_data_dialog (about_prefs , ba , wait )
52+ cookie_value = _open_clear_cookies_data_dialog (about_prefs , ba )
7553 assert cookie_value > 0 , f"Expected cookie/site data > 0, got { cookie_value } "
7654
77- # Clear cookies and site data: open dialog again, wait for iframe, click clear
55+ # Clear cookies and site data: open the dialog again, wait for iframe, click clear
7856 about_prefs .open ()
79- dlg_iframe = about_prefs .press_button_get_popup_dialog_iframe ( "Clear Data" )
57+ dlg_iframe = about_prefs .clear_cookies_and_get_dialog_iframe ( )
8058 wait .until (lambda _ : dlg_iframe and dlg_iframe .is_displayed ())
8159 ba .switch_to_iframe_context (dlg_iframe )
8260 about_prefs .get_element ("clear-data-accept-button" ).click ()
8361 ba .switch_to_content_context ()
8462
8563 # Wait until the dialog reports 0 (reopen/poll via helper)
86- wait .until (lambda _ : _open_clear_cookies_data_dialog (about_prefs , ba , wait ) == 0 )
64+ wait .until (lambda _ : _open_clear_cookies_data_dialog (about_prefs , ba ) == 0 )
8765
88- final_value = _open_clear_cookies_data_dialog (about_prefs , ba , wait )
66+ final_value = _open_clear_cookies_data_dialog (about_prefs , ba )
8967 assert final_value == 0 , f"Expected 0 after clearing, got { final_value } "
0 commit comments