From 0ebc5c6618f44fc91d40b5c7b80158121c77ad32 Mon Sep 17 00:00:00 2001 From: soncuteanca Date: Tue, 21 Oct 2025 19:10:49 +0300 Subject: [PATCH 1/4] Add 3029116 --- modules/browser_object_context_menu.py | 7 ++- modules/browser_object_navigation.py | 10 +++ modules/data/about_newtab.components.json | 13 +++- modules/data/context_menu.components.json | 31 ++++++++++ modules/data/navigation.components.json | 6 ++ modules/page_object_newtab.py | 41 +++++++++++++ modules/page_object_prefs.py | 4 +- ...n_sponsored_topsite_context_menu_option.py | 61 +++++++++++++++++++ tests/preferences/test_clear_cookie_data.py | 5 +- 9 files changed, 169 insertions(+), 9 deletions(-) create mode 100644 tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py diff --git a/modules/browser_object_context_menu.py b/modules/browser_object_context_menu.py index 5683c4a5c..6dd28cc07 100644 --- a/modules/browser_object_context_menu.py +++ b/modules/browser_object_context_menu.py @@ -13,15 +13,16 @@ class ContextMenu(BasePage): URL_TEMPLATE = "" + @BasePage.context_chrome def click_context_item( self, reference: Union[str, tuple, WebElement], labels=[] ) -> BasePage: """ Clicks the context item. """ - with self.driver.context(self.driver.CONTEXT_CHROME): - self.fetch(reference, labels=labels).click() - return self + + self.fetch(reference, labels=labels).click() + return self class AboutDownloadsContextMenu(ContextMenu): diff --git a/modules/browser_object_navigation.py b/modules/browser_object_navigation.py index 655e54090..8f692a66c 100644 --- a/modules/browser_object_navigation.py +++ b/modules/browser_object_navigation.py @@ -750,3 +750,13 @@ def verify_autoplay_state(self, expected: Literal["allow", "block"]) -> None: else: self.element_visible("permission-popup-audio-video-blocked") self.element_visible("autoplay-icon-blocked") + + @BasePage.context_chrome + def get_status_panel_url(self) -> str: + """ + Gets the URL displayed in the status panel at the bottom left of the browser. + """ + self.element_visible("status-panel-label") + status_label = self.get_element("status-panel-label") + url = status_label.get_attribute("value") + return url diff --git a/modules/data/about_newtab.components.json b/modules/data/about_newtab.components.json index 7780038c9..aa6aad156 100644 --- a/modules/data/about_newtab.components.json +++ b/modules/data/about_newtab.components.json @@ -89,5 +89,16 @@ "selectorData": "logo", "strategy": "class", "groups": [] - } + }, + + "top-site-by-title": { + "selectorData": "//li[@class='top-site-outer']//span[@class='title-label' and text()='{title}']/..", + "strategy": "xpath", + "groups": [] +}, + "status-panel-label": { + "selectorData": "statuspanel-label", + "strategy": "id", + "groups": [] + } } diff --git a/modules/data/context_menu.components.json b/modules/data/context_menu.components.json index e9afb106e..5cd900673 100644 --- a/modules/data/context_menu.components.json +++ b/modules/data/context_menu.components.json @@ -221,5 +221,36 @@ "selectorData": "placesContext_openBookmarkContainer:tabs", "strategy": "id", "groups": [] + }, + + "context-menu-open-link-in-container-tab": { + "selectorData": "context-openlinkinusercontext-menu", + "strategy": "id", + "groups": [] + }, + + "context-menu-bookmark-link": { + "selectorData": "context-bookmarklink", + "strategy": "id", + "groups": [] + }, + + "context-menu-inspect-a11y": { + "selectorData": "context-inspect-a11y", + "strategy": "id", + "groups": [] + }, + + "context-menu-ask-chatbot": { + "selectorData": "context-ask-chat", + "strategy": "id", + "groups": [] + + }, + "context-menu-search-select": { + "selectorData": "context-searchselect", + "strategy": "id", + "groups": [] } + } diff --git a/modules/data/navigation.components.json b/modules/data/navigation.components.json index 61c18f3c9..3165f2a5e 100644 --- a/modules/data/navigation.components.json +++ b/modules/data/navigation.components.json @@ -603,5 +603,11 @@ "selectorData": "developer-button", "strategy": "id", "groups": [] + }, + + "status-panel-label": { + "selectorData": "statuspanel-label", + "strategy": "id", + "groups": [] } } diff --git a/modules/page_object_newtab.py b/modules/page_object_newtab.py index e2f467cd1..bf497cbaf 100644 --- a/modules/page_object_newtab.py +++ b/modules/page_object_newtab.py @@ -1,8 +1,10 @@ import logging +from selenium.webdriver import Firefox from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement +from modules.browser_object_navigation import Navigation from modules.page_base import BasePage @@ -45,6 +47,10 @@ class AboutNewtab(BasePage): TOP_SITES_TOTAL = [7, 8] REC_ARTICLE_TOTAL = 21 + def __init__(self, driver: Firefox, **kwargs): + super().__init__(driver, **kwargs) + self.navigation = Navigation(driver) + def set_language_code(self, lang_code: str) -> BasePage: """ Set the language code of the object, set self.constants as well @@ -132,3 +138,38 @@ def check_layout(self) -> BasePage: logging.info(f"Found {self.count_top_sites()} top sites") # ODD: Sometimes we get 7 top sites, not 8 assert self.count_top_sites() in self.TOP_SITES_TOTAL + + @BasePage.context_content + def get_topsite_element(self, tile_title: str): + """Get a top site tile element by title.""" + return self.get_element("top-site-by-title", labels=[tile_title]) + + @BasePage.context_content + def open_topsite_context_menu_by_title(self, tile_title: str): + """ + Opens the context menu for a top site tile by its title. + Argument: + tile_title: The title text of the tile (eg. "Wikipedia") + """ + # Get the tile by title and right-click on it to open context menu + tile = self.get_topsite_element(tile_title) + self.context_click(tile) + return self + + @BasePage.context_content + def hover_topsite_and_verify_url(self, tile_title: str, expected_url: str): + """ + Hovers over a top site tile and verifies the status panel shows the expected URL, displayed in the + bottom-left corner of the new tab window. + Arguments: + tile_title: The title text of the tile (e.g., "Wikipedia") + expected_url: The expected URL to be displayed in the status panel + """ + tile = self.get_topsite_element(tile_title) + self.hover(tile) + navigation = Navigation(self.driver) + actual_url = navigation.get_status_panel_url() + assert expected_url in actual_url, ( + f"Expected '{expected_url}' in '{actual_url}'" + ) + return self diff --git a/modules/page_object_prefs.py b/modules/page_object_prefs.py index 36c30f92e..b54024ba2 100644 --- a/modules/page_object_prefs.py +++ b/modules/page_object_prefs.py @@ -430,8 +430,8 @@ def press_button_get_popup_dialog_iframe(self, button_label: str) -> WebElement: Returns the iframe object for the dialog panel in the popup after pressing some button that triggers a popup """ # hack to know if the current iframe is the default browser one or not - if self.get_iframe().location['x'] > 0: - self.click_on('close-dialog') + if self.get_iframe().location["x"] > 0: + self.click_on("close-dialog") self.click_on("prefs-button", labels=[button_label]) iframe = self.get_element("browser-popup") return iframe diff --git a/tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py b/tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py new file mode 100644 index 000000000..372cb8c86 --- /dev/null +++ b/tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py @@ -0,0 +1,61 @@ +import pytest +from selenium.webdriver import Firefox + +from modules.browser_object_context_menu import ContextMenu +from modules.browser_object_navigation import Navigation +from modules.browser_object_tabbar import TabBar +from modules.page_object_generics import GenericPage +from modules.page_object_newtab import AboutNewtab + + +@pytest.fixture() +def test_case(): + return "3029116" + + +EXPECTED_CONTEXT_MENU_OPTIONS = { + "context-menu-open-link-in-tab": "Open Link in New Tab", + "context-menu-open-link-in-new-window": "Open Link in New Window", + "context-menu-open-link-in-new-private-window": "Open Link in New Private Window", + "context-menu-bookmark-link": "Bookmark Link", + "context-menu-save-link": "Save Link As...", + "context-menu-copy-link": "Copy Link", + "context-menu-search-select": "Search Google for", + "context-menu-ask-chatbot": "Ask an AI Chatbot", + "context-menu-inspect": "Inspect", +} + +TOPSITE_TITLE = "Wikipedia" + + +def test_non_sponsored_topsite_context_menu_option(driver: Firefox) -> None: + """ + C3029116 - Verifies that the browser's context menu displays the expected options + when right-clicking a top site tile, and that the opened link matches the + status panel URL shown on hover. + """ + # Instantiate page objects + tabs = TabBar(driver) + newtab = AboutNewtab(driver) + context_menu = ContextMenu(driver) + nav = Navigation(driver) + page = GenericPage(driver, url="about:newtab") + + # Hover over Wikipedia tile and capture the status panel URL (browser's bottom-left corner) + page.open() + newtab.hover_topsite_and_verify_url(TOPSITE_TITLE, "wikipedia.org") + status_panel_url = nav.get_status_panel_url() + + # Right-click on the Wikipedia tile to open context menu + newtab.open_topsite_context_menu_by_title(TOPSITE_TITLE) + + # Verify all expected context menu options are present + for selector, description in EXPECTED_CONTEXT_MENU_OPTIONS.items(): + context_menu.element_visible(selector) + + # Click "Open Link in New Tab" from context menu + context_menu.click_context_item("context-menu-open-link-in-tab") + + # Switch to the newly opened tab + tabs.switch_to_new_tab() + nav.url_contains(status_panel_url) diff --git a/tests/preferences/test_clear_cookie_data.py b/tests/preferences/test_clear_cookie_data.py index ff820354d..09fb80998 100644 --- a/tests/preferences/test_clear_cookie_data.py +++ b/tests/preferences/test_clear_cookie_data.py @@ -14,9 +14,8 @@ def test_case(): WEBSITE_ADDRESS = "https://www.wikipedia.com" # WIN_GHA = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith("win") -def _open_clear_cookies_data_dialog( - about_prefs: AboutPrefs, ba: BrowserActions -): + +def _open_clear_cookies_data_dialog(about_prefs: AboutPrefs, ba: BrowserActions): """ Open about:preferences#privacy, show the 'Clear Data' dialog, switch into its iframe, wait for its option container to be present, read the value, then switch back. From 3e3a89d7ed27c497864342d656c47400a146ccff Mon Sep 17 00:00:00 2001 From: soncuteanca Date: Wed, 22 Oct 2025 13:34:39 +0300 Subject: [PATCH 2/4] method changes, added dynamic elements --- modules/browser_object_context_menu.py | 47 ++++++++++++++++++- modules/browser_object_navigation.py | 11 +++++ modules/page_object_newtab.py | 18 ------- ...n_sponsored_topsite_context_menu_option.py | 30 ++++++------ 4 files changed, 73 insertions(+), 33 deletions(-) diff --git a/modules/browser_object_context_menu.py b/modules/browser_object_context_menu.py index 6dd28cc07..0813bea34 100644 --- a/modules/browser_object_context_menu.py +++ b/modules/browser_object_context_menu.py @@ -1,5 +1,5 @@ import logging -from typing import Union +from typing import Dict, List, Union from selenium.webdriver.remote.webelement import WebElement @@ -24,6 +24,51 @@ def click_context_item( self.fetch(reference, labels=labels).click() return self + @BasePage.context_chrome + def get_menu_item_label(self, selector: str) -> str: + """ + Returns the label text of a context menu item, normalized. + """ + el = self.get_element(selector) + return (el.get_attribute("label") or el.text or "").strip() + + @BasePage.context_chrome + def verify_topsites_tile_context_menu_options( + self, + static_items: Dict[str, str], + dynamic_items: List[str], + tile_title: str, + ): + """ + Verifies expected context menu items are visible and optionally checks label match. + Arguments: + static_items: Dict mapping of selector name to expected label text. + dynamic_items: List of selector names for items with dynamic labels. + tile_title: Optional, required if dynamic label validation is needed (e.g., Wikipedia, YouTube). + """ + # --- Static items --- + for selector, expected_label in static_items.items(): + option = self.get_element(selector) + label = (option.get_attribute("label") or option.text or "").strip() + print(f"[DEBUG] Static label for {selector}: {label}") + assert expected_label in label, ( + f'Expected label "{expected_label}" not found. Got: "{label}"' + ) + + # --- Dynamic items --- + for selector in dynamic_items: + option = self.get_element(selector) + label = (option.get_attribute("label") or option.text or "").strip() + normalized = label.lower() + print(f"[DEBUG] Dynamic label for {selector}: {label}") + assert normalized.startswith("search"), ( + f'Label does not start with "Search": "{label}"' + ) + assert "for" in normalized, f'"for" not found in label: "{label}"' + assert tile_title.lower() in normalized, ( + f'Search term "{tile_title}" not found in label: "{label}"' + ) + class AboutDownloadsContextMenu(ContextMenu): """ diff --git a/modules/browser_object_navigation.py b/modules/browser_object_navigation.py index 8f692a66c..b2aae6b89 100644 --- a/modules/browser_object_navigation.py +++ b/modules/browser_object_navigation.py @@ -760,3 +760,14 @@ def get_status_panel_url(self) -> str: status_label = self.get_element("status-panel-label") url = status_label.get_attribute("value") return url + + def verify_status_panel_url(self, expected_url: str): + """ + Asserts that the browser status panel (bottom-left) contains the expected URL. + Argument: + expected_url: The expected URL substring to be found in the status panel + """ + actual_url = self.get_status_panel_url() + assert expected_url in actual_url, ( + f"Expected '{expected_url}' in status panel URL, got '{actual_url}'" + ) diff --git a/modules/page_object_newtab.py b/modules/page_object_newtab.py index bf497cbaf..cba0fa861 100644 --- a/modules/page_object_newtab.py +++ b/modules/page_object_newtab.py @@ -155,21 +155,3 @@ def open_topsite_context_menu_by_title(self, tile_title: str): tile = self.get_topsite_element(tile_title) self.context_click(tile) return self - - @BasePage.context_content - def hover_topsite_and_verify_url(self, tile_title: str, expected_url: str): - """ - Hovers over a top site tile and verifies the status panel shows the expected URL, displayed in the - bottom-left corner of the new tab window. - Arguments: - tile_title: The title text of the tile (e.g., "Wikipedia") - expected_url: The expected URL to be displayed in the status panel - """ - tile = self.get_topsite_element(tile_title) - self.hover(tile) - navigation = Navigation(self.driver) - actual_url = navigation.get_status_panel_url() - assert expected_url in actual_url, ( - f"Expected '{expected_url}' in '{actual_url}'" - ) - return self diff --git a/tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py b/tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py index 372cb8c86..cfd3b628b 100644 --- a/tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py +++ b/tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py @@ -13,19 +13,20 @@ def test_case(): return "3029116" -EXPECTED_CONTEXT_MENU_OPTIONS = { +STATIC_CONTEXT_MENU_OPTIONS = { "context-menu-open-link-in-tab": "Open Link in New Tab", "context-menu-open-link-in-new-window": "Open Link in New Window", "context-menu-open-link-in-new-private-window": "Open Link in New Private Window", "context-menu-bookmark-link": "Bookmark Link", - "context-menu-save-link": "Save Link As...", + "context-menu-save-link": "Save Link As", "context-menu-copy-link": "Copy Link", - "context-menu-search-select": "Search Google for", - "context-menu-ask-chatbot": "Ask an AI Chatbot", "context-menu-inspect": "Inspect", } +DYNAMIC_CONTEXT_MENU_ITEMS = ["context-menu-search-select"] + TOPSITE_TITLE = "Wikipedia" +TOPSITE_URL = "www.wikipedia.org" def test_non_sponsored_topsite_context_menu_option(driver: Firefox) -> None: @@ -34,28 +35,29 @@ def test_non_sponsored_topsite_context_menu_option(driver: Firefox) -> None: when right-clicking a top site tile, and that the opened link matches the status panel URL shown on hover. """ - # Instantiate page objects tabs = TabBar(driver) newtab = AboutNewtab(driver) context_menu = ContextMenu(driver) nav = Navigation(driver) page = GenericPage(driver, url="about:newtab") - # Hover over Wikipedia tile and capture the status panel URL (browser's bottom-left corner) + # Open about:newtab and hover over Wikipedia tile page.open() - newtab.hover_topsite_and_verify_url(TOPSITE_TITLE, "wikipedia.org") + title_element = newtab.get_topsite_element(TOPSITE_TITLE) + newtab.hover(title_element) + nav.verify_status_panel_url(TOPSITE_URL) status_panel_url = nav.get_status_panel_url() - # Right-click on the Wikipedia tile to open context menu + # Right-click to open context menu newtab.open_topsite_context_menu_by_title(TOPSITE_TITLE) - # Verify all expected context menu options are present - for selector, description in EXPECTED_CONTEXT_MENU_OPTIONS.items(): - context_menu.element_visible(selector) + context_menu.verify_topsites_tile_context_menu_options( + STATIC_CONTEXT_MENU_OPTIONS, + DYNAMIC_CONTEXT_MENU_ITEMS, + TOPSITE_TITLE, + ) - # Click "Open Link in New Tab" from context menu + # Click first option and verify link opens in new tab context_menu.click_context_item("context-menu-open-link-in-tab") - - # Switch to the newly opened tab tabs.switch_to_new_tab() nav.url_contains(status_panel_url) From a7c2c3da094b1fc06c8c811fd002000bb93adb69 Mon Sep 17 00:00:00 2001 From: soncuteanca Date: Wed, 22 Oct 2025 14:32:28 +0300 Subject: [PATCH 3/4] Removed unnecessary code, provide selector info --- SELECTOR_INFO.md | 31 ++++++++++++++++++- modules/browser_object_context_menu.py | 12 +------ modules/browser_object_navigation.py | 2 +- modules/data/about_newtab.components.json | 7 +---- modules/data/context_menu.components.json | 20 +----------- modules/page_object_newtab.py | 10 ++---- ...n_sponsored_topsite_context_menu_option.py | 3 +- 7 files changed, 38 insertions(+), 47 deletions(-) diff --git a/SELECTOR_INFO.md b/SELECTOR_INFO.md index f838f7671..afba91574 100644 --- a/SELECTOR_INFO.md +++ b/SELECTOR_INFO.md @@ -443,6 +443,14 @@ Description: The Firefox logo Location: The about:newtab page Path to .json: modules/data/about_newtab.components.json ``` +``` +Selector Name: top-site-by-title +Selector Data: "//li[@class='top-site-outer']//span[@class='title-label' and text()='{title}']/.." +Description: Topsite tile by title +Location: The about:newtab page (middle section) +Path to .json: modules/data/about_newtab.components.json +``` + #### about_prefs ``` Selector Name: search-engine-dropdown-root @@ -1830,6 +1838,20 @@ Description: Context menu option to move a tab to the start of the tab bar. Location: Context menu - Tab Path to .json: modules/data/context_menu.components.json ``` +``` +Selector Name: context-menu-bookmark-link +Selector Data: context-bookmarklink +Description: Context menu option to bookmark a link +Location: Context menu - topsite context menu +Path to .json: modules/data/context_menu.components.json +``` +``` +Selector Name: context-menu-search-select +Selector Data: coontext-searchselect +Description: Context menu option to search selected text with the engine set as default +Location: Context menu - topsite context menu +Path to .json: modules/data/context_menu.components.json +``` #### credit_card_fill ``` Selector Name: form-field @@ -3132,6 +3154,13 @@ Description: Developer tool icon Location: Navigation bar Path to .json: modules/data/navigation.components.json ``` +``` +Selector Name: status-panel-label +Selector Data: statuspanel-label +Description: Status panel URL label +Location: newtab page bottom left corner on link hover +Path to .json: modules/data/navigation.components.json +``` #### panel_ui ``` Selector name: panel-ui-button @@ -3509,7 +3538,7 @@ Description: Edit bookmark panel Location: Bookmark panel Path to .json: modules/data/pane_ui.components.json ``` -``` + #### print_preview ``` Selector name: print-preview-browser diff --git a/modules/browser_object_context_menu.py b/modules/browser_object_context_menu.py index 0813bea34..6e3b95214 100644 --- a/modules/browser_object_context_menu.py +++ b/modules/browser_object_context_menu.py @@ -24,14 +24,6 @@ def click_context_item( self.fetch(reference, labels=labels).click() return self - @BasePage.context_chrome - def get_menu_item_label(self, selector: str) -> str: - """ - Returns the label text of a context menu item, normalized. - """ - el = self.get_element(selector) - return (el.get_attribute("label") or el.text or "").strip() - @BasePage.context_chrome def verify_topsites_tile_context_menu_options( self, @@ -40,7 +32,7 @@ def verify_topsites_tile_context_menu_options( tile_title: str, ): """ - Verifies expected context menu items are visible and optionally checks label match. + Verifies expected context menu options are present upon right clicking a topsite tile. Arguments: static_items: Dict mapping of selector name to expected label text. dynamic_items: List of selector names for items with dynamic labels. @@ -50,7 +42,6 @@ def verify_topsites_tile_context_menu_options( for selector, expected_label in static_items.items(): option = self.get_element(selector) label = (option.get_attribute("label") or option.text or "").strip() - print(f"[DEBUG] Static label for {selector}: {label}") assert expected_label in label, ( f'Expected label "{expected_label}" not found. Got: "{label}"' ) @@ -60,7 +51,6 @@ def verify_topsites_tile_context_menu_options( option = self.get_element(selector) label = (option.get_attribute("label") or option.text or "").strip() normalized = label.lower() - print(f"[DEBUG] Dynamic label for {selector}: {label}") assert normalized.startswith("search"), ( f'Label does not start with "Search": "{label}"' ) diff --git a/modules/browser_object_navigation.py b/modules/browser_object_navigation.py index b2aae6b89..f451fc87f 100644 --- a/modules/browser_object_navigation.py +++ b/modules/browser_object_navigation.py @@ -763,7 +763,7 @@ def get_status_panel_url(self) -> str: def verify_status_panel_url(self, expected_url: str): """ - Asserts that the browser status panel (bottom-left) contains the expected URL. + Verify that the browser status panel (browser's bottom-left) contains the expected URL. Argument: expected_url: The expected URL substring to be found in the status panel """ diff --git a/modules/data/about_newtab.components.json b/modules/data/about_newtab.components.json index aa6aad156..9279a1268 100644 --- a/modules/data/about_newtab.components.json +++ b/modules/data/about_newtab.components.json @@ -95,10 +95,5 @@ "selectorData": "//li[@class='top-site-outer']//span[@class='title-label' and text()='{title}']/..", "strategy": "xpath", "groups": [] -}, - "status-panel-label": { - "selectorData": "statuspanel-label", - "strategy": "id", - "groups": [] - } +} } diff --git a/modules/data/context_menu.components.json b/modules/data/context_menu.components.json index 5cd900673..d84d6bc6f 100644 --- a/modules/data/context_menu.components.json +++ b/modules/data/context_menu.components.json @@ -223,30 +223,12 @@ "groups": [] }, - "context-menu-open-link-in-container-tab": { - "selectorData": "context-openlinkinusercontext-menu", - "strategy": "id", - "groups": [] - }, - "context-menu-bookmark-link": { "selectorData": "context-bookmarklink", "strategy": "id", "groups": [] - }, - - "context-menu-inspect-a11y": { - "selectorData": "context-inspect-a11y", - "strategy": "id", - "groups": [] - }, - - "context-menu-ask-chatbot": { - "selectorData": "context-ask-chat", - "strategy": "id", - "groups": [] - }, + "context-menu-search-select": { "selectorData": "context-searchselect", "strategy": "id", diff --git a/modules/page_object_newtab.py b/modules/page_object_newtab.py index cba0fa861..6c6e492a7 100644 --- a/modules/page_object_newtab.py +++ b/modules/page_object_newtab.py @@ -1,10 +1,8 @@ import logging -from selenium.webdriver import Firefox from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement -from modules.browser_object_navigation import Navigation from modules.page_base import BasePage @@ -47,10 +45,6 @@ class AboutNewtab(BasePage): TOP_SITES_TOTAL = [7, 8] REC_ARTICLE_TOTAL = 21 - def __init__(self, driver: Firefox, **kwargs): - super().__init__(driver, **kwargs) - self.navigation = Navigation(driver) - def set_language_code(self, lang_code: str) -> BasePage: """ Set the language code of the object, set self.constants as well @@ -141,13 +135,13 @@ def check_layout(self) -> BasePage: @BasePage.context_content def get_topsite_element(self, tile_title: str): - """Get a top site tile element by title.""" + """Get a topsite tile element by title.""" return self.get_element("top-site-by-title", labels=[tile_title]) @BasePage.context_content def open_topsite_context_menu_by_title(self, tile_title: str): """ - Opens the context menu for a top site tile by its title. + Opens the context menu for a topsite tile by its title. Argument: tile_title: The title text of the tile (eg. "Wikipedia") """ diff --git a/tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py b/tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py index cfd3b628b..eef52a4bc 100644 --- a/tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py +++ b/tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py @@ -41,7 +41,7 @@ def test_non_sponsored_topsite_context_menu_option(driver: Firefox) -> None: nav = Navigation(driver) page = GenericPage(driver, url="about:newtab") - # Open about:newtab and hover over Wikipedia tile + # Open about:newtab and hover over the topsite tite and verify status panel URL (bottom-left) page.open() title_element = newtab.get_topsite_element(TOPSITE_TITLE) newtab.hover(title_element) @@ -51,6 +51,7 @@ def test_non_sponsored_topsite_context_menu_option(driver: Firefox) -> None: # Right-click to open context menu newtab.open_topsite_context_menu_by_title(TOPSITE_TITLE) + # Verify context menu options context_menu.verify_topsites_tile_context_menu_options( STATIC_CONTEXT_MENU_OPTIONS, DYNAMIC_CONTEXT_MENU_ITEMS, From c2fc90ee7a0bfd551eaccd7a948a2a1063eff712 Mon Sep 17 00:00:00 2001 From: soncuteanca Date: Thu, 23 Oct 2025 11:51:14 +0300 Subject: [PATCH 4/4] Fix typo --- .../test_non_sponsored_topsite_context_menu_option.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py b/tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py index eef52a4bc..b1a622b4d 100644 --- a/tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py +++ b/tests/address_bar_and_search/test_non_sponsored_topsite_context_menu_option.py @@ -41,7 +41,7 @@ def test_non_sponsored_topsite_context_menu_option(driver: Firefox) -> None: nav = Navigation(driver) page = GenericPage(driver, url="about:newtab") - # Open about:newtab and hover over the topsite tite and verify status panel URL (bottom-left) + # Open about:newtab and hover over the desired TOPSITE_TITLE tile and verify status panel URL (bottom-left) page.open() title_element = newtab.get_topsite_element(TOPSITE_TITLE) newtab.hover(title_element)