Skip to content

Commit af16b9f

Browse files
committed
merge changes in
2 parents dba16ed + abadc46 commit af16b9f

30 files changed

+430
-50
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_panel_ui.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,12 @@ def start_sync(self) -> BasePage:
132132
self.element_has_text("fxa-sync-label", "Sync now")
133133
self.get_element("fxa-sync-label").click()
134134
return self
135+
136+
def open_private_window(self) -> BasePage:
137+
"""
138+
Opens a new window in private browsing mode using the panel
139+
"""
140+
self.open_panel_menu()
141+
with self.driver.context(self.driver.CONTEXT_CHROME):
142+
self.get_element("panel-ui-new-private-window").click()
143+
return self

modules/browser_object_tabbar.py

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,29 @@ def new_window_by_keys(self, sys_platform: str) -> BasePage:
6565
).perform()
6666
return self
6767

68+
def reopen_closed_tab_by_keys(self, sys_platform: str) -> BasePage:
69+
"""Use keyboard shortcut to reopen a last closed tab"""
70+
if sys_platform == "Darwin":
71+
self.actions.key_down(Keys.COMMAND).key_down(Keys.SHIFT).send_keys(
72+
"t"
73+
).key_up(Keys.SHIFT).key_up(Keys.COMMAND).perform()
74+
else:
75+
self.actions.key_down(Keys.CONTROL).key_down(Keys.SHIFT).send_keys(
76+
"t"
77+
).key_up(Keys.SHIFT).key_up(Keys.CONTROL).perform()
78+
return self
79+
6880
def click_tab_by_title(self, title: str) -> BasePage:
6981
"""Given a full page title, click the corresponding tab"""
7082
with self.driver.context(self.driver.CONTEXT_CHROME):
7183
self.get_element("tab-by-title", labels=[title]).click()
7284
return self
7385

86+
def get_tab_by_title(self, title: str) -> BasePage:
87+
"""Given a full page title, return the corresponding tab"""
88+
with self.driver.context(self.driver.CONTEXT_CHROME):
89+
return self.get_element("tab-by-title", labels=[title])
90+
7491
def click_tab_by_index(self, index: int) -> BasePage:
7592
"""Given a tab index (int), click the corresponding tab"""
7693
with self.driver.context(self.driver.CONTEXT_CHROME):
@@ -236,23 +253,23 @@ def scroll_on_all_tabs_menu(self, down=True, pixels=200) -> BasePage:
236253
logging.info(f"menu location: {menu.location}")
237254
logging.info(f"menu size: {menu.size}")
238255

239-
def get_bar_y():
240-
return min(
241-
[
242-
menu.size["height"] // 2,
243-
self.driver.get_window_size()["height"] // 2,
244-
]
245-
)
246-
247256
# HACK: Can't figure out what the scrollbox selector is, but it's ~4 pixels
248257
# off the edge of the menu.
249-
x_start = menu.location["x"] + menu.size["width"] - 4
250-
# Grab the middle of the scrollbox area, most likely to hold the bar
251-
y_start = menu.location["y"] + get_bar_y()
258+
x_start = (menu.size["width"] / 2.0) - 4.0
252259
# +Y is down, -Y is up
253260
sign = 1 if down else -1
254-
self.actions.move_by_offset(x_start, y_start)
261+
262+
self.actions.move_to_element_with_offset(menu, x_start, 0)
255263
self.actions.click_and_hold()
256264
self.actions.move_by_offset(0, (sign * pixels))
257265
self.actions.release()
258266
self.actions.perform()
267+
268+
def close_tab(self, tab: WebElement) -> BasePage:
269+
"""
270+
Given the index of the tab, it closes that tab.
271+
"""
272+
# cur_tab = self.click_tab_by_index(index)
273+
with self.driver.context(self.driver.CONTEXT_CHROME):
274+
self.get_element("tab-x-icon", parent_element=tab).click()
275+
return self

modules/data/about_prefs.components.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,18 @@
258258
"groups": []
259259
},
260260

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+
261273
"cookies-shadow-root": {
262274
"selectorData": "dialog[buttons='accept,cancel']",
263275
"strategy": "css",
@@ -281,6 +293,30 @@
281293
]
282294
},
283295

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+
284320
"language-dropdown": {
285321
"selectorData": "primaryBrowserLocale",
286322
"strategy": "id",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"main-logo": {
3+
"selectorData": "about-private-browsing-logo",
4+
"strategy": "id",
5+
"groups": [
6+
"requiredForPage"
7+
]
8+
}
9+
10+
}

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
@@ -202,5 +202,23 @@
202202
"selectorData": "protections-popup-no-trackers-found-description",
203203
"strategy": "id",
204204
"groups": []
205+
},
206+
207+
"lock-icon": {
208+
"selectorData": "identity-icon",
209+
"strategy": "id",
210+
"groups": []
211+
},
212+
213+
"connection-secure-button": {
214+
"selectorData": "identity-popup-security-button",
215+
"strategy": "id",
216+
"groups": []
217+
},
218+
219+
"more-information-button": {
220+
"selectorData": "identity-popup-more-info",
221+
"strategy": "id",
222+
"groups": []
205223
}
206224
}

modules/data/panel_ui.components.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
]
4242
},
4343

44+
"new-private-window-option": {
45+
"selectorData": "appMenu-new-private-window-button2",
46+
"strategy": "id",
47+
"groups": []
48+
},
49+
4450
"more-tools": {
4551
"selectorData": "appMenu-more-button2",
4652
"strategy": "id",
@@ -115,6 +121,12 @@
115121
"groups": []
116122
},
117123

124+
"panel-ui-new-private-window": {
125+
"selectorData": "appMenu-new-private-window-button2",
126+
"strategy": "id",
127+
"groups": []
128+
},
129+
118130
"panel-ui-history-recent-history-container": {
119131
"selectorData": "appMenu_historyMenu",
120132
"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_base.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,11 @@ def url_contains(self, url_part: str) -> Page:
391391
self.expect(EC.url_contains(url_part))
392392
return self
393393

394+
def title_contains(self, url_part: str) -> Page:
395+
"""Expect helper: wait until driver URL contains given text or timeout"""
396+
self.expect(EC.title_contains(url_part))
397+
return self
398+
394399
def verify_opened_image_url(self, url_substr: str, pattern: str) -> Page:
395400
"""
396401
Given a part of a URL and a regex, wait for that substring to exist in
@@ -537,10 +542,21 @@ def wait_for_num_tabs(self, num_tabs: int) -> Page:
537542
logging.warn("Timeout waiting for the number of windows to be:", num_tabs)
538543
return self
539544

540-
def switch_to_new_tab(self):
545+
def switch_to_new_tab(self) -> Page:
541546
"""Get list of all window handles, switch to the newly opened tab"""
542547
handles = self.driver.window_handles
543548
self.driver.switch_to.window(handles[-1])
549+
return self
550+
551+
def wait_for_num_windows(self, num: int) -> Page:
552+
"""Wait for the number of open tabs + windows to equal given int"""
553+
with self.driver.context(self.driver.CONTEXT_CONTENT):
554+
return self.wait_for_num_tabs(num)
555+
556+
def switch_to_new_window(self) -> Page:
557+
"""Switch to newest window"""
558+
with self.driver.context(self.driver.CONTEXT_CONTENT):
559+
return self.switch_to_new_tab()
544560

545561
def hide_popup(self, context_menu: str, chrome=False) -> Page:
546562
"""

0 commit comments

Comments
 (0)