Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions SELECTOR_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,20 @@ Description: Context menu option to search selected text with the engine set as
Location: Context menu - topsite context menu
Path to .json: modules/data/context_menu.components.json
```
```
Selector Name: context-menu-open-link-in-new_container_tab
Selector Data: context-openlinkinusercontext-menu"
Description: Open linkin new container tab context menu item
Location: Newpage topsites tile context menu
Path to .json: modules/data/context_menu.components.json
```
```
Selector Name: context-menu-open-link-in-container-work
Selector Data: menuitem[data-l10n-id='user-context-work']"
Description: Open link in container "Work" context submenu item
Location: Newpage topsites tile submenu context menu, secodn option
Path to .json: modules/data/context_menu.components.json
```
#### credit_card_fill
```
Selector Name: form-field
Expand Down Expand Up @@ -3329,6 +3343,13 @@ Description: Switch to clipboard
Location: Address bar
Path to .json: modules/data/navigation.components.json
```
```
Selector Name: tab-container-label
Selector Data: "userContext-label"
Description: Tab container label
Location: URL bar when a tab container is active
Path to .json: modules/data/navigation.components.json
```
#### panel_ui
```
Selector name: panel-ui-button
Expand Down
4 changes: 4 additions & 0 deletions manifests/key.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ address_bar_and_search:
result: pass
splits:
- functional1
test_open_link_in_new_container_tab:
result: pass
splits:
- functional1
test_paste_and_go_opens_correct_url:
result: pass
splits:
Expand Down
7 changes: 7 additions & 0 deletions modules/browser_object_context_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ def click_context_item(
self.fetch(reference, labels=labels).click()
return self

@BasePage.context_chrome
def open_link_in_container(self) -> BasePage:
"""Open a link from the context menu in a specific container tab."""
self.click_context_item("context-menu-open-link-in-new_container_tab")
self.click_context_item("context-menu-open-link-in-container-work")
return self

@BasePage.context_chrome
def verify_topsites_tile_context_menu_options(
self,
Expand Down
43 changes: 43 additions & 0 deletions modules/browser_object_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1189,3 +1189,46 @@ def verify_no_autofill_adaptive_elements(self) -> BasePage:
"Adaptive history autofill suggestion was not removed after deletion."
)
return self

@BasePage.context_chrome
def verify_autofill_adaptive_element(
self, expected_type: str, expected_url: str
) -> BasePage:
"""
Verify that the adaptive history autofill element has the expected type and URL text.
This method handles chrome context switching internally.
Arguments:
expected_type: Expected type attribute value
expected_url: Expected URL fragment to be contained in the element text
"""
autofill_element = self.get_element("search-result-autofill-adaptive-element")
actual_type = autofill_element.get_attribute("type")
actual_text = autofill_element.text

assert actual_type == expected_type
assert expected_url in actual_text

return self

@BasePage.context_chrome
def verify_no_autofill_adaptive_elements(self) -> BasePage:
"""Verify that no adaptive history autofill elements are present."""
autofill_elements = self.get_elements("search-result-autofill-adaptive-element")
if autofill_elements:
logging.warning(
f"Unexpected adaptive autofill elements found: {[el.text for el in autofill_elements]}"
)
assert len(autofill_elements) == 0, (
"Adaptive history autofill suggestion was not removed after deletion."
)
return self

@BasePage.context_chrome
def expect_container_label(self, label_expected: str):
"""
Verify the container label for user context (container tabs).
Argument:
label_expected: The expected label text for the user context container.
"""
actual_label = self.get_element("tab-container-label").text
assert actual_label == label_expected
14 changes: 13 additions & 1 deletion modules/data/context_menu.components.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@
"groups": []
},

"context-menu-open-link-in-new_container_tab": {
"selectorData": "context-openlinkinusercontext-menu",
"strategy": "id",
"groups": []
},

"context-menu-toolbar-open-in-new-tab": {
"selectorData": "placesContext_open:newtab",
"strategy": "id",
Expand Down Expand Up @@ -233,6 +239,12 @@
"selectorData": "context-searchselect",
"strategy": "id",
"groups": []
}
},

"context-menu-open-link-in-container-work": {
"selectorData": "menuitem[data-l10n-id='user-context-work']",
"strategy": "css",
"groups": []
}

}
6 changes: 6 additions & 0 deletions modules/data/navigation.components.json
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,12 @@
"groups": ["doNotCache"]
},

"tab-container-label": {
"selectorData": "userContext-label",
"strategy": "id",
"groups": []
},

"clipboard-suggestion": {
"selectorData": "#urlbar-results > div.urlbarView-row[type='clipboard']",
"strategy": "css",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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 "3029117"


@pytest.fixture()
def add_to_prefs_list():
return [("privacy.userContext.enabled", True)]


TOPSITE_TITLE = "Wikipedia"
TOPSITE_URL = "www.wikipedia.org"
EXPECTED_CONTAINER = "Work"


def test_open_link_in_new_container_tab(driver: Firefox) -> None:
"""
C3029117 - Verify that a link opened from the context menu in a new container tab opens
in the correct container and URL.
"""
tabs = TabBar(driver)
new_tab = AboutNewtab(driver)
context_menu = ContextMenu(driver)
nav = Navigation(driver)
page = GenericPage(driver, url="about:newtab")

# Open about:newtab and right-click to open context menu
page.open()
new_tab.open_topsite_context_menu_by_title(TOPSITE_TITLE)

# Click first option and verify link opens in new tab
context_menu.open_link_in_container()

# Switch to new tab and verify URL and container
tabs.switch_to_new_tab()
nav.url_contains(TOPSITE_URL)
nav.expect_container_label(EXPECTED_CONTAINER)