Skip to content

Commit c912059

Browse files
committed
Merge branch 'main' into sl/firefox-never-rmb-history
2 parents 34d2f69 + a6feeb7 commit c912059

8 files changed

+63
-14
lines changed

modules/browser_object_context_menu.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Union
2+
13
from selenium.webdriver.remote.webelement import WebElement
24

35
from modules.page_base import BasePage
@@ -17,9 +19,20 @@ def get_context_item(self, item: str) -> WebElement:
1719
with self.driver.context(self.driver.CONTEXT_CHROME):
1820
return self.get_element(item)
1921

20-
def click_context_item(self, context_element: WebElement) -> BasePage:
22+
def click_context_item(
23+
self, reference: Union[str, tuple, WebElement], labels=[]
24+
) -> BasePage:
2125
"""
2226
Clicks the context item.
2327
"""
2428
with self.driver.context(self.driver.CONTEXT_CHROME):
25-
context_element.click()
29+
self.fetch(reference, labels=labels).click()
30+
return self
31+
32+
def click_and_hide(
33+
self, reference: Union[str, tuple, WebElement], labels=[]
34+
) -> BasePage:
35+
with self.driver.context(self.driver.CONTEXT_CHROME):
36+
self.fetch(reference, labels=labels).click()
37+
self.hide_popup_by_child_node(reference, labels=labels)
38+
return self

modules/data/context_menu.components.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
"groups": []
88
},
99

10+
"context-menu-open-link-in-new-private-window": {
11+
"selectorData": "context-openlinkprivate",
12+
"strategy": "id",
13+
"groups": []
14+
},
15+
1016
"context-menu-inspect": {
1117
"selectorData": "context-inspect",
1218
"strategy": "id",

modules/page_base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ def switch_to_new_window(self) -> Page:
558558
with self.driver.context(self.driver.CONTEXT_CONTENT):
559559
return self.switch_to_new_tab()
560560

561-
def hide_popup(self, context_menu: str, chrome=False) -> Page:
561+
def hide_popup(self, context_menu: str, chrome=True) -> Page:
562562
"""
563563
Given the ID of the context menu, it will dismiss the menu.
564564
@@ -586,15 +586,15 @@ def hide_popup_by_class(self, class_name: str) -> None:
586586
"""
587587
self.driver.execute_script(script)
588588

589-
def hide_popup_by_child_node(self, node: WebElement, chrome=False) -> Page:
589+
def hide_popup_by_child_node(
590+
self, reference: Union[str, tuple, WebElement], labels=[]
591+
) -> Page:
592+
node = self.fetch(reference, labels=labels)
590593
script = """var element = arguments[0].parentNode;
591594
if (element && element.hidePopup) {
592595
element.hidePopup();
593596
}"""
594-
if chrome:
595-
with self.driver.context(self.driver.CONTEXT_CHROME):
596-
self.driver.execute_script(script, node)
597-
else:
597+
with self.driver.context(self.context_id):
598598
self.driver.execute_script(script, node)
599599

600600
@property

modules/page_object_example_page.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ class ExamplePage(BasePage):
77
"""
88

99
URL_TEMPLATE = "https://example.com/"
10+
TITLE = "Example Domain"
11+
MORE_INFO_URL = "https://www.iana.org/help/example-domains"
12+
MORE_INFO_TITLE = "Example Domains"

tests/menus/test_frequently_used_context_menu.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_save_page_as(driver: Firefox):
3232

3333
save_page_as = context_menu.get_context_item("context-menu-save-page-as")
3434
context_menu.click_context_item(save_page_as)
35-
context_menu.hide_popup_by_child_node(save_page_as, chrome=True)
35+
context_menu.hide_popup_by_child_node(save_page_as)
3636

3737
downloads_button = nav.get_download_button()
3838

@@ -87,7 +87,7 @@ def test_take_screenshot(driver: Firefox):
8787
# context click the screenshot option and verify its not hidden
8888
take_screenshot = context_menu.get_context_item("context-menu-take-screenshot")
8989
context_menu.click_context_item(take_screenshot)
90-
context_menu.hide_popup_by_child_node(take_screenshot, chrome=True)
90+
context_menu.hide_popup_by_child_node(take_screenshot)
9191

9292
with driver.context(driver.CONTEXT_CHROME):
9393
screenshot_box = example_page.get_element("take-screenshot-box")
@@ -110,5 +110,5 @@ def test_inspect(driver: Firefox):
110110

111111
inspect_option = context_menu.get_context_item("context-menu-inspect")
112112
context_menu.click_context_item(inspect_option)
113-
context_menu.hide_popup_by_child_node(inspect_option, chrome=True)
113+
context_menu.hide_popup_by_child_node(inspect_option)
114114
devtools.check_opened()

tests/menus/test_image_context_menu_actions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_open_image_in_new_tab(driver: Firefox):
3636
"context-menu-open-image-in-new-tab"
3737
)
3838
image_context_menu.click_context_item(open_in_new_tab)
39-
wiki_image_page.hide_popup_by_child_node(open_in_new_tab, chrome=True)
39+
image_context_menu.hide_popup_by_child_node(open_in_new_tab)
4040

4141
# switch to the second tab and verify the URL
4242
tabs.wait_for_num_tabs(2)
@@ -71,7 +71,7 @@ def test_save_image_as(driver: Firefox):
7171
# save it
7272
save_image_as = image_context_menu.get_context_item("context-menu-save-image-as")
7373
image_context_menu.click_context_item(save_image_as)
74-
wiki_image_page.hide_popup_by_child_node(save_image_as, chrome=True)
74+
image_context_menu.hide_popup_by_child_node(save_image_as)
7575

7676
# create the pynput controller
7777
downloads_button = nav.get_download_button()
@@ -130,7 +130,7 @@ def test_copy_image_link(driver: Firefox):
130130
"context-menu-copy-image-link"
131131
)
132132
image_context_menu.click_context_item(copy_image_link)
133-
wiki_image_page.hide_popup_by_child_node(copy_image_link, chrome=True)
133+
image_context_menu.hide_popup_by_child_node(copy_image_link)
134134

135135
# open a new tab
136136
tabs.new_tab_by_button()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import logging
2+
3+
import pytest
4+
from selenium.webdriver import Firefox
5+
6+
from modules.browser_object import ContextMenu, Navigation
7+
from modules.page_object import ExamplePage, GenericPage
8+
9+
10+
def test_open_link_in_private_window(driver: Firefox):
11+
"""C101662 - Links can be successfully opened in a Private Browsing session"""
12+
example = ExamplePage(driver)
13+
example.open()
14+
context_menu = ContextMenu(driver)
15+
nav = Navigation(driver)
16+
17+
example.context_click("more-information")
18+
context_menu.click_and_hide("context-menu-open-link-in-new-private-window")
19+
nav.wait_for_num_windows(2)
20+
nav.switch_to_new_window()
21+
with driver.context(driver.CONTEXT_CHROME):
22+
nav.title_contains("Private Browsing")
23+
example.title_contains(example.MORE_INFO_TITLE)
24+
example.url_contains(example.MORE_INFO_URL)

tests/sync_and_fxa/test_new_fxa.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ def acct_password():
1515
return "Test123???"
1616

1717

18+
@pytest.mark.skip(
19+
"Stop spamming stage with fake accounts; remove when we implement acct delete"
20+
)
1821
def test_sync_new_fxa(driver: Firefox, fxa_url: str, new_fxa_prep: dict, get_otp_code):
1922
"""C131094: The user is able to create a new Firefox Account"""
2023

0 commit comments

Comments
 (0)