|
| 1 | +import pytest |
| 2 | +from selenium.webdriver import Firefox |
| 3 | + |
| 4 | +from modules.browser_object_context_menu import ContextMenu |
| 5 | +from modules.browser_object_navigation import Navigation |
| 6 | +from modules.browser_object_tabbar import TabBar |
| 7 | +from modules.page_object_generics import GenericPage |
| 8 | +from modules.page_object_newtab import AboutNewtab |
| 9 | + |
| 10 | + |
| 11 | +@pytest.fixture() |
| 12 | +def test_case(): |
| 13 | + return "3029116" |
| 14 | + |
| 15 | + |
| 16 | +STATIC_CONTEXT_MENU_OPTIONS = { |
| 17 | + "context-menu-open-link-in-tab": "Open Link in New Tab", |
| 18 | + "context-menu-open-link-in-new-window": "Open Link in New Window", |
| 19 | + "context-menu-open-link-in-new-private-window": "Open Link in New Private Window", |
| 20 | + "context-menu-bookmark-link": "Bookmark Link", |
| 21 | + "context-menu-save-link": "Save Link As", |
| 22 | + "context-menu-copy-link": "Copy Link", |
| 23 | + "context-menu-inspect": "Inspect", |
| 24 | +} |
| 25 | + |
| 26 | +DYNAMIC_CONTEXT_MENU_ITEMS = ["context-menu-search-select"] |
| 27 | + |
| 28 | +TOPSITE_TITLE = "Wikipedia" |
| 29 | +TOPSITE_URL = "www.wikipedia.org" |
| 30 | + |
| 31 | + |
| 32 | +def test_non_sponsored_topsite_context_menu_option(driver: Firefox) -> None: |
| 33 | + """ |
| 34 | + C3029116 - Verifies that the browser's context menu displays the expected options |
| 35 | + when right-clicking a top site tile, and that the opened link matches the |
| 36 | + status panel URL shown on hover. |
| 37 | + """ |
| 38 | + tabs = TabBar(driver) |
| 39 | + newtab = AboutNewtab(driver) |
| 40 | + context_menu = ContextMenu(driver) |
| 41 | + nav = Navigation(driver) |
| 42 | + page = GenericPage(driver, url="about:newtab") |
| 43 | + |
| 44 | + # Open about:newtab and hover over the desired TOPSITE_TITLE tile and verify status panel URL (bottom-left) |
| 45 | + page.open() |
| 46 | + title_element = newtab.get_topsite_element(TOPSITE_TITLE) |
| 47 | + newtab.hover(title_element) |
| 48 | + nav.verify_status_panel_url(TOPSITE_URL) |
| 49 | + status_panel_url = nav.get_status_panel_url() |
| 50 | + |
| 51 | + # Right-click to open context menu |
| 52 | + newtab.open_topsite_context_menu_by_title(TOPSITE_TITLE) |
| 53 | + |
| 54 | + # Verify context menu options |
| 55 | + context_menu.verify_topsites_tile_context_menu_options( |
| 56 | + STATIC_CONTEXT_MENU_OPTIONS, |
| 57 | + DYNAMIC_CONTEXT_MENU_ITEMS, |
| 58 | + TOPSITE_TITLE, |
| 59 | + ) |
| 60 | + |
| 61 | + # Click first option and verify link opens in new tab |
| 62 | + context_menu.click_context_item("context-menu-open-link-in-tab") |
| 63 | + tabs.switch_to_new_tab() |
| 64 | + nav.url_contains(status_panel_url) |
0 commit comments