Skip to content

Commit bc50395

Browse files
committed
merge main in
2 parents 6b0143c + ecb1fe0 commit bc50395

19 files changed

+322
-28
lines changed

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ pypom = "*"
1616
jsonpath-ng = "*"
1717
pillow = "*"
1818
pyfxa = "*"
19+
ruff = "0.5.2"
1920
pytest-rerunfailures = "*"
2021

2122
[dev-packages]
2223
werkzeug = "*"
2324
selenium-wire = "*"
2425
pdoc = "*"
25-
ruff = "0.4.3"
2626
pytest-variables = "*"
2727
taskcluster-taskgraph = "*"

modules/browser_object_tabbar.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ def new_tab_by_keys(self, sys_platform: str) -> BasePage:
5353
).perform()
5454
return self
5555

56+
def new_window_by_keys(self, sys_platform: str) -> BasePage:
57+
"""Use keyboard shortcut to open a new tab"""
58+
if sys_platform == "Darwin":
59+
self.actions.key_down(Keys.COMMAND).send_keys("n").key_up(
60+
Keys.COMMAND
61+
).perform()
62+
else:
63+
self.actions.key_down(Keys.CONTROL).send_keys("n").key_up(
64+
Keys.CONTROL
65+
).perform()
66+
return self
67+
5668
def reopen_closed_tab_by_keys(self, sys_platform: str) -> BasePage:
5769
"""Use keyboard shortcut to reopen a last closed tab"""
5870
if sys_platform == "Darwin":
@@ -241,22 +253,13 @@ def scroll_on_all_tabs_menu(self, down=True, pixels=200) -> BasePage:
241253
logging.info(f"menu location: {menu.location}")
242254
logging.info(f"menu size: {menu.size}")
243255

244-
def get_bar_y():
245-
return min(
246-
[
247-
menu.size["height"] // 2,
248-
self.driver.get_window_size()["height"] // 2,
249-
]
250-
)
251-
252256
# HACK: Can't figure out what the scrollbox selector is, but it's ~4 pixels
253257
# off the edge of the menu.
254-
x_start = menu.location["x"] + menu.size["width"] - 4
255-
# Grab the middle of the scrollbox area, most likely to hold the bar
256-
y_start = menu.location["y"] + get_bar_y()
258+
x_start = (menu.size["width"] / 2.0) - 4.0
257259
# +Y is down, -Y is up
258260
sign = 1 if down else -1
259-
self.actions.move_by_offset(x_start, y_start)
261+
262+
self.actions.move_to_element_with_offset(menu, x_start, 0)
260263
self.actions.click_and_hold()
261264
self.actions.move_by_offset(0, (sign * pixels))
262265
self.actions.release()

modules/data/about_prefs.components.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@
216216
"groups": []
217217
},
218218

219+
"home-new-window-dropdown": {
220+
"selectorData": "homeMode",
221+
"strategy": "id",
222+
"groups": []
223+
},
224+
219225
"home-new-tabs-dropdown-option-default": {
220226
"selectorData": "menuitem[data-l10n-id=\"home-mode-choice-default-fx\"]",
221227
"strategy": "css",
@@ -252,6 +258,18 @@
252258
"groups": []
253259
},
254260

261+
"notifications-allow-button": {
262+
"selectorData": "button[class='popup-notification-primary-button primary footer-button']",
263+
"strategy": "css",
264+
"groups": []
265+
},
266+
267+
"notifications-block-button": {
268+
"selectorData": "button[class='popup-notification-secondary-button footer-button']",
269+
"strategy": "css",
270+
"groups": []
271+
},
272+
255273
"cookies-shadow-root": {
256274
"selectorData": "dialog[buttons='accept,cancel']",
257275
"strategy": "css",
@@ -275,6 +293,30 @@
275293
]
276294
},
277295

296+
"permissions-notifications-button": {
297+
"selectorData": "notificationSettingsButton",
298+
"strategy": "id",
299+
"groups": []
300+
},
301+
302+
"permissions-notifications-popup-websites": {
303+
"selectorData": "permissionsBox",
304+
"strategy": "id",
305+
"groups": []
306+
},
307+
308+
"permissions-notifications-popup-websites-item": {
309+
"selectorData": "richlistitem[origin='{name}']",
310+
"strategy": "css",
311+
"groups": []
312+
},
313+
314+
"permissions-notifications-popup-websites-item-status": {
315+
"selectorData": "website-status",
316+
"strategy": "class",
317+
"groups": []
318+
},
319+
278320
"language-dropdown": {
279321
"selectorData": "primaryBrowserLocale",
280322
"strategy": "id",

modules/data/generic_page.components.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@
55
"groups": []
66
},
77

8+
"authorize-notifications-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": []
18+
},
19+
820
"mediawiki-image": {
921
"selectorData": "mw-mmv-image",
1022
"strategy": "class",

modules/data/navigation.components.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,5 +210,23 @@
210210
"selectorData": "protections-popup-no-trackers-found-description",
211211
"strategy": "id",
212212
"groups": []
213+
},
214+
215+
"lock-icon": {
216+
"selectorData": "identity-icon",
217+
"strategy": "id",
218+
"groups": []
219+
},
220+
221+
"connection-secure-button": {
222+
"selectorData": "identity-popup-security-button",
223+
"strategy": "id",
224+
"groups": []
225+
},
226+
227+
"more-information-button": {
228+
"selectorData": "identity-popup-more-info",
229+
"strategy": "id",
230+
"groups": []
213231
}
214232
}

modules/data/panel_ui.components.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@
9191
]
9292
},
9393

94+
"panel-ui-new-window": {
95+
"selectorData": "appMenu-new-window-button2",
96+
"strategy": "id",
97+
"groups": []
98+
},
99+
94100
"panel-ui-history": {
95101
"selectorData": "appMenu-history-button",
96102
"strategy": "id",

modules/data/tab_bar.components.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@
6969
]
7070
},
7171

72+
"all-tabs-menu-scrollbar": {
73+
"selectorData": "#alltabs-popup scrollbox",
74+
"strategy": "css",
75+
"groups": [
76+
"allTabsMenu"
77+
]
78+
},
79+
7280
"all-tabs-entry": {
7381
"selectorData": "all-tabs-item",
7482
"strategy": "class",

modules/page_object_about_prefs.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ def __init__(self, page, **kwargs):
4646
def loaded(self):
4747
return self.root if EC.element_to_be_clickable(self.root) else False
4848

49-
def select_option(self, option_name: str, double_click=False):
49+
def select_option(
50+
self, option_name: str, double_click=False, wait_for_selection=True
51+
):
5052
"""Select an option in the dropdown. Does not return self."""
5153
if not self.dropmarker.get_attribute("open") == "true":
5254
self.root.click()
@@ -64,6 +66,7 @@ def select_option(self, option_name: str, double_click=False):
6466
)
6567
else:
6668
matching_menuitems[0].click()
69+
if wait_for_selection:
6770
self.wait.until(EC.element_to_be_selected(matching_menuitems[0]))
6871
return self
6972
else:
@@ -313,3 +316,9 @@ def get_clear_cookie_data_value(self) -> int:
313316
return number
314317
else:
315318
print("No number found in the string")
319+
320+
def get_iframe(self) -> WebElement:
321+
"""
322+
Gets the webelement for the iframe that commonly appears in about:preferences
323+
"""
324+
return self.get_element("browser-popup")

modules/util.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from os import remove
88
from random import shuffle
99
from typing import List, Literal, Union
10+
from urllib.parse import urlparse, urlunparse
1011

1112
from faker import Faker
1213
from faker.providers import internet, misc
@@ -370,6 +371,16 @@ def assert_json_value(self, json_data, jsonpath_expr, expected_value):
370371
f"Expected {expected_value}, but got {match[0].value}",
371372
)
372373

374+
def get_domain_from_url(self, url: str) -> str:
375+
"""
376+
Given a URL, it will extract the domain of the URL.
377+
378+
For example, "https://www.example.com/path/to/page?query=123#fragment" will product "https://www.example.com"
379+
"""
380+
parsed_url = urlparse(url)
381+
domain_parsed_url = parsed_url._replace(path="")
382+
return urlunparse(domain_parsed_url)
383+
373384

374385
class BrowserActions:
375386
"""

tests/address_bar_and_search/test_google_withads_url_bar_us.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import time
1+
from time import sleep
22

33
import pytest
44
from selenium.webdriver import Firefox
@@ -23,9 +23,9 @@ def test_google_withads_url_bar_us(driver: Firefox):
2323
util = Utilities()
2424

2525
nav.search("iphone")
26-
time.sleep(5)
26+
sleep(5)
2727
about_telemetry = AboutTelemetry(driver).open()
28-
time.sleep(5)
28+
sleep(5)
2929

3030
# Click on Raw JSON, switch tab and click on Raw Data
3131
about_telemetry.get_element("category-raw").click()

0 commit comments

Comments
 (0)