diff --git a/modules/data/about_config.components.json b/modules/data/about_config.components.json index 71fad83e..7019219d 100644 --- a/modules/data/about_config.components.json +++ b/modules/data/about_config.components.json @@ -60,4 +60,5 @@ "selectorData": "changemp", "strategy": "id", "groups": [] + } } diff --git a/modules/page_base.py b/modules/page_base.py index f255c4f5..04e2d404 100644 --- a/modules/page_base.py +++ b/modules/page_base.py @@ -116,6 +116,11 @@ def opposite_context(self): else self.driver.CONTEXT_CHROME ) + def is_private(self): + """Determine if current browsing context is private""" + with self.driver.context(self.driver.CONTEXT_CHROME): + return "Private Browsing" in self.driver.title + def custom_wait(self, **kwargs) -> WebDriverWait: """ Create a custom WebDriverWait object, refer to Selenium docs @@ -671,8 +676,7 @@ def wait_for_num_tabs(self, num_tabs: int) -> Page: def switch_to_new_tab(self) -> Page: """Get list of all window handles, switch to the newly opened tab""" - handles = self.driver.window_handles - self.driver.switch_to.window(handles[-1]) + self.driver.switch_to.window(self.driver.window_handles[-1]) return self def wait_for_num_windows(self, num: int) -> Page: diff --git a/tests/bookmarks_and_history/test_deleted_page_not_remembered.py b/tests/bookmarks_and_history/test_deleted_page_not_remembered.py index 56050efa..02194111 100644 --- a/tests/bookmarks_and_history/test_deleted_page_not_remembered.py +++ b/tests/bookmarks_and_history/test_deleted_page_not_remembered.py @@ -1,19 +1,8 @@ -import logging -import platform -from os import environ - import pytest from selenium.webdriver import Firefox from modules.browser_object import ContextMenu, Navigation, PanelUi -X_PADDING = 50 -if ( - platform.system().lower().startswith("win") - and environ.get("GITHUB_ACTIONS") == "true" -): - X_PADDING += 25 - @pytest.fixture() def test_case(): @@ -25,6 +14,7 @@ def use_profile(): return "theme_change" +@pytest.mark.headed def test_deleted_page_not_remembered(driver: Firefox, sys_platform): """ C216273: Verify that the deleted page from the Hamburger History submenu is not remembered or autofilled in the URL bar @@ -35,18 +25,7 @@ def test_deleted_page_not_remembered(driver: Firefox, sys_platform): context_menu = ContextMenu(driver) panel_ui.open_history_menu() - history_items = panel_ui.get_all_history() - - firefox_privacy_notice = history_items[-1] - with driver.context(driver.CONTEXT_CHROME): - x_offset = firefox_privacy_notice.size.get("width") + X_PADDING - logging.info(x_offset) - if sys_platform.lower() == "linux": - panel_ui.click_on(firefox_privacy_notice) - else: - panel_ui.actions.move_to_element_with_offset( - firefox_privacy_notice, x_offset, 0 - ).click().perform() + panel_ui.context_click("bookmark-by-title", labels=["Firefox Privacy Notice"]) context_menu.click_and_hide_menu("context-menu-delete-page") nav.type_in_awesome_bar("Firefox Privacy Notice") diff --git a/tests/bookmarks_and_history/test_open_bookmark_in_new_window_via_toolbar_context_menu.py b/tests/bookmarks_and_history/test_open_bookmark_in_new_window_via_toolbar_context_menu.py index 5792d961..ca5df04b 100644 --- a/tests/bookmarks_and_history/test_open_bookmark_in_new_window_via_toolbar_context_menu.py +++ b/tests/bookmarks_and_history/test_open_bookmark_in_new_window_via_toolbar_context_menu.py @@ -1,3 +1,6 @@ +import platform +from os import environ + import pytest from selenium.webdriver import Firefox @@ -13,6 +16,10 @@ def test_case(): URL_TO_BOOKMARK = "https://www.mozilla.org/" +@pytest.mark.xfail( + platform.system() == "Darwin" and environ.get("GITHUB_ACTIONS") == "true", + reason="Test failing in Mac GHA", +) def test_open_bookmark_in_new_window_via_toolbar_context_menu(driver: Firefox): """ C2084552: Verify that a bookmarked page can be open in a New Window from Toolbar context menu. @@ -35,9 +42,10 @@ def test_open_bookmark_in_new_window_via_toolbar_context_menu(driver: Firefox): "bookmark-by-title", labels=["Internet for people"] ) context_menu.context_click(bookmarked_page) - context_menu.get_element("context-menu-toolbar-open-in-new-window").click() + context_menu.click_and_hide_menu("context-menu-toolbar-open-in-new-window") # Verify that the test page is opened in a new normal window driver.switch_to.window(driver.window_handles[-1]) - nav.element_not_visible("private-browsing-icon") + assert not nav.is_private() + page.url_contains("mozilla") diff --git a/tests/bookmarks_and_history/test_open_bookmark_in_private_window_via_toolbar_context_menu.py b/tests/bookmarks_and_history/test_open_bookmark_in_private_window_via_toolbar_context_menu.py index 3916365c..9e7df7b8 100644 --- a/tests/bookmarks_and_history/test_open_bookmark_in_private_window_via_toolbar_context_menu.py +++ b/tests/bookmarks_and_history/test_open_bookmark_in_private_window_via_toolbar_context_menu.py @@ -1,3 +1,6 @@ +import platform +from os import environ + import pytest from selenium.webdriver import Firefox @@ -13,6 +16,10 @@ def test_case(): URL_TO_BOOKMARK = "https://www.mozilla.org/" +@pytest.mark.xfail( + platform.system() == "Darwin" and environ.get("GITHUB_ACTIONS") == "true", + reason="Test failing in Mac GHA", +) def test_open_bookmark_in_new_private_window_via_toolbar_context_menu(driver: Firefox): """ C2084553: Verify that a bookmarked page can be open in a New Private Window from Toolbar context menu. @@ -36,11 +43,12 @@ def test_open_bookmark_in_new_private_window_via_toolbar_context_menu(driver: Fi "bookmark-by-title", labels=["Internet for people"] ) context_menu.context_click(bookmarked_page) - context_menu.get_element( + context_menu.click_and_hide_menu( "context-menu-toolbar-open-in-new-private-window" - ).click() + ) # Verify that the test page is opened in a new private window driver.switch_to.window(driver.window_handles[-1]) - nav.element_visible("private-browsing-icon") + assert nav.is_private() + page.url_contains("mozilla") diff --git a/tests/security_and_privacy/test_undo_close_tab_private_browsing.py b/tests/security_and_privacy/test_undo_close_tab_private_browsing.py index fefc5761..725ae6b5 100644 --- a/tests/security_and_privacy/test_undo_close_tab_private_browsing.py +++ b/tests/security_and_privacy/test_undo_close_tab_private_browsing.py @@ -57,8 +57,7 @@ def test_undo_close_tab_private_browsing(driver: Firefox, sys_platform: str): tabs.reopen_closed_tab_by_keys(sys_platform) tabs.wait_for_num_tabs(2) tabs.switch_to_new_tab() - logging.info(f"The observed title in the chrome context is {driver.title}") - tabs.title_contains("Private Browsing") + assert nav.is_private() logging.info(f"The observed title in the content context is {driver.title}") - generic_page.title_contains("About About") + generic_page.url_contains("about:about")