Skip to content

Commit 1d84126

Browse files
authored
Merge branch 'main' into sl/notifications-set-change
2 parents b0ae095 + 428a09d commit 1d84126

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

modules/data/about_prefs.components.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,20 @@
263263
"strategy": "css",
264264
"groups": []
265265
},
266+
267+
"cookies-shadow-root": {
268+
"selectorData": "dialog[buttons='accept,cancel']",
269+
"strategy": "css",
270+
"groups": [
271+
"doNotCache"
272+
]
273+
},
274+
275+
"clear-data-dialog-options": {
276+
"selectorData": "hbox.checkbox-label-box",
277+
"strategy": "css",
278+
"groups": []
279+
},
266280

267281
"permissions-notifications-button": {
268282
"selectorData": "notificationSettingsButton",
@@ -288,6 +302,15 @@
288302
"groups": []
289303
},
290304

305+
"clear-data-accept-button": {
306+
"selectorData": "[class='button-text'][value='Clear']",
307+
"strategy": "css",
308+
"shadowParent": "cookies-shadow-root",
309+
"groups": [
310+
"doNotCache"
311+
]
312+
},
313+
291314
"language-dropdown": {
292315
"selectorData": "primaryBrowserLocale",
293316
"strategy": "id",

modules/page_object_about_prefs.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from modules.classes.autofill_base import AutofillAddressBase
1111
from modules.classes.credit_card import CreditCardBase
1212
from modules.page_base import BasePage
13-
from modules.util import PomUtils
13+
from modules.util import BrowserActions, PomUtils
1414

1515

1616
class AboutPrefs(BasePage):
@@ -289,8 +289,35 @@ def get_save_addresses_popup_iframe(self) -> WebElement:
289289
iframe = self.get_element("browser-popup")
290290
return iframe
291291

292+
292293
def get_iframe(self) -> WebElement:
293294
"""
294295
Gets the webelement for the iframe that commonly appears in about:preferences
295296
"""
296297
return self.get_element("browser-popup")
298+
299+
300+
def get_clear_cookie_data_value(self) -> int:
301+
"""
302+
With the 'Clear browsing data and cookies' popup open,
303+
returns the <memory used> value of the option for 'Cookies and site data (<memory used>)'.
304+
The <memory used> value for no cookies is '0 bytes', otherwise values are '### MB', or '### KB'
305+
"""
306+
# Find the dialog option elements containing the checkbox label
307+
options = self.get_elements("clear-data-dialog-options")
308+
309+
# Extract the text from the label the second option
310+
second_option = options[1]
311+
label_text = second_option.text
312+
print(f"The text of the option is: {label_text}")
313+
314+
# Use a regular expression to find the memory usage
315+
match = re.search(r"\d+", label_text)
316+
317+
if match:
318+
number_str = match.group() # Extract the matched number as a string
319+
number = int(number_str) # Convert the number to an integer
320+
print(f"The extracted value is: {number}")
321+
return number
322+
else:
323+
print("No number found in the string")
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from selenium.webdriver import Firefox
2+
3+
from modules.page_object import AboutPrefs
4+
from modules.util import BrowserActions
5+
6+
7+
def test_clear_cookie_data(driver: Firefox):
8+
"""
9+
C143627: Cookies and site data can be cleared via the "Clear Data" panel
10+
"""
11+
# Instantiate objects
12+
about_prefs = AboutPrefs(driver, category="privacy")
13+
ba = BrowserActions(driver)
14+
15+
def open_clear_cookies_data_dialog():
16+
about_prefs.open()
17+
clear_data_popup = about_prefs.press_button_get_popup_dialog_iframe(
18+
"Clear Data…"
19+
)
20+
ba.switch_to_iframe_context(clear_data_popup)
21+
22+
# Visit a site to get a cookie added to saved data
23+
driver.get("https://www.mozilla.org")
24+
25+
# Navigate to the clear data dialog of about:preferences#privacy
26+
open_clear_cookies_data_dialog()
27+
28+
# Check for a non-zero value of the 'Cookies and site data' option
29+
cookie_value = about_prefs.get_clear_cookie_data_value()
30+
assert cookie_value is not 0
31+
32+
# Then clear the cookies and site data
33+
about_prefs.get_element("clear-data-accept-button").click()
34+
35+
# Finally, check the value of the dialog option, it should be 0
36+
open_clear_cookies_data_dialog()
37+
cookie_value2 = about_prefs.get_clear_cookie_data_value()
38+
assert cookie_value2 is 0

0 commit comments

Comments
 (0)