Skip to content

Commit 12a96c7

Browse files
committed
formatting + notifcations
1 parent 8600804 commit 12a96c7

11 files changed

+133
-4
lines changed

modules/data/about_prefs.components.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,5 +250,41 @@
250250
"selectorData": "contentBlockingFingerprintingProtectionCheckbox",
251251
"strategy": "id",
252252
"groups": []
253+
},
254+
255+
"notifications-allow-button": {
256+
"selectorData": "button[class='popup-notification-primary-button primary footer-button']",
257+
"strategy": "css",
258+
"groups": []
259+
},
260+
261+
"notifications-block-button": {
262+
"selectorData": "button[class='popup-notification-secondary-button footer-button']",
263+
"strategy": "css",
264+
"groups": []
265+
},
266+
267+
"permissions-notifications-button": {
268+
"selectorData": "notificationSettingsButton",
269+
"strategy": "id",
270+
"groups": []
271+
},
272+
273+
"permissions-notifications-popup-websites": {
274+
"selectorData": "permissionsBox",
275+
"strategy": "id",
276+
"groups": []
277+
},
278+
279+
"permissions-notifications-popup-websites-item": {
280+
"selectorData": "richlistitem[origin='{name}']",
281+
"strategy": "css",
282+
"groups": []
283+
},
284+
285+
"permissions-notifications-popup-websites-item-status": {
286+
"selectorData": "website-status",
287+
"strategy": "class",
288+
"groups": []
253289
}
254290
}

modules/data/generic_page.components.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,17 @@
33
"selectorData": "body",
44
"strategy": "tag",
55
"groups": []
6+
},
7+
8+
"authorize-notiifcations-button": {
9+
"selectorData": "button[onclick='notify.authorize()']",
10+
"strategy": "css",
11+
"groups": []
12+
},
13+
14+
"show-notifications-button": {
15+
"selectorData": "button[onclick='notify.show()']",
16+
"strategy": "css",
17+
"groups": []
618
}
719
}

modules/page_object_about_prefs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,9 @@ def get_save_addresses_popup_iframe(self) -> WebElement:
283283
self.get_element("prefs-button", labels=["Saved addresses"]).click()
284284
iframe = self.get_element("browser-popup")
285285
return iframe
286+
287+
def get_iframe(self) -> WebElement:
288+
"""
289+
Gets the webelement for the iframe that commonly appears in about:preferences
290+
"""
291+
return self.get_element("browser-popup")

modules/util.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,22 @@ def assert_json_value(self, json_data, jsonpath_expr, expected_value):
370370
f"Expected {expected_value}, but got {match[0].value}",
371371
)
372372

373+
def trim_url_to_last_slash(self, url: str):
374+
"""
375+
Given a URL, it will create a copy and trim it to the first slash. It does not include the last / after trimming.
376+
"""
377+
# Find the position of the last slash
378+
last_slash_index = url.rfind("/")
379+
380+
# Slice the string up to and including the last slash
381+
if last_slash_index != -1:
382+
trimmed_url = url[:last_slash_index]
383+
else:
384+
logging.warn("Couldn't find the last instance of a /.")
385+
trimmed_url = url
386+
387+
return trimmed_url
388+
373389

374390
class BrowserActions:
375391
"""

tests/address_bar_and_search/test_google_search_counts_us.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from time import sleep
22

3-
import pytest
43
from selenium.webdriver import Firefox
54

65
from modules.browser_object import Navigation

tests/address_bar_and_search/test_sap_google_adclick.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import time
22

3-
import pytest
43
from selenium.webdriver import Firefox
54

65
from modules.browser_object_navigation import Navigation

tests/security_and_privacy/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ def set_prefs(add_prefs: dict):
1111
"""Set prefs"""
1212
prefs = []
1313
prefs.extend(add_prefs)
14-
return prefs
14+
return prefs

tests/security_and_privacy/test_blocking_cryptominers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
import pytest
44
from selenium.webdriver import Firefox
5+
56
from modules.browser_object_navigation import Navigation
67
from modules.page_object_about_prefs import AboutPrefs
78

89
CRYPTOMINERS_URL = "https://senglehardt.com/test/trackingprotection/test_pages/fingerprinting_and_cryptomining.html"
910

11+
1012
@pytest.fixture()
1113
def add_prefs():
1214
return []
1315

16+
1417
def test_blocking_cryptominers(driver: Firefox):
1518
# instantiate objects
1619
nav = Navigation(driver).open()

tests/security_and_privacy/test_cryptominers_blocked_and_shown_in_info_panel.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import pytest
44
from selenium.webdriver import Firefox
5+
56
from modules.browser_object_navigation import Navigation
67

78
CRYPTOMINERS_URL = "https://senglehardt.com/test/trackingprotection/test_pages/fingerprinting_and_cryptomining.html"
89

10+
911
@pytest.fixture()
1012
def add_prefs():
1113
return []

tests/security_and_privacy/test_no_trackers_detected.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import pytest
22
from selenium.webdriver import Firefox
3+
34
from modules.browser_object_navigation import Navigation
45

56
NOTRACKERS_URL = "http://example.com/"
67

8+
79
@pytest.fixture()
810
def add_prefs():
911
return []
@@ -20,4 +22,4 @@ def test_no_trackers_detected(driver: Firefox):
2022
# Click on the shield icon and verify that trackers are detected
2123
with driver.context(driver.CONTEXT_CHROME):
2224
nav.get_element("shield-icon").click()
23-
assert nav.get_element("no-trackers-detected").is_displayed()
25+
assert nav.get_element("no-trackers-detected").is_displayed()

0 commit comments

Comments
 (0)