Skip to content

Commit 1561ad2

Browse files
Sangie50Tracy-Walker
authored andcommitted
test 1976523 passed locally
1 parent 85be701 commit 1561ad2

File tree

5 files changed

+75
-2
lines changed

5 files changed

+75
-2
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
/.vscode/
22
/venv/
33
.env
44
.report.json

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pytest = "<8.4"
1111
pytest-httpserver = "1.0.12"
1212
requests = "<3.0"
1313
pytest-xdist = "3.6.1"
14-
pytest-html = "4.1.1"
1514
pypom = "2.2.4"
1615
taskcluster-taskgraph = "==9.0.0"
1716
jsonpath-ng = "1.6.1"
@@ -25,6 +24,7 @@ google-auth = "2.32.0"
2524
psutil = "<6.1"
2625
pytest-json-report = "==1.5.0"
2726
beautifulsoup4 = "4.12.3"
27+
pytest-html = "*"
2828

2929
[dev-packages]
3030
werkzeug = "==3.0.3"

modules/browser_object_navigation.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,30 @@ def open_bookmark_from_toolbar(self, bookmark_title: str) -> BasePage:
569569
self.panel_ui.click_on("bookmark-by-title", labels=[bookmark_title])
570570
return self
571571

572+
@BasePage.context_chrome
573+
def open_bookmark_in_new_tab_via_context_menu(
574+
self, bookmark_title: str
575+
) -> BasePage:
576+
"""
577+
Right-click bookmark and opens it in a new tab via context menu
578+
579+
Argument:
580+
bookmark_title: The title of the bookmark to open
581+
"""
582+
# Right-click the bookmark to make the menu appear
583+
self.panel_ui.element_clickable("bookmark-by-title", labels=[bookmark_title])
584+
self.panel_ui.context_click("bookmark-by-title", labels=[bookmark_title])
585+
586+
# Find the menu item we want to click
587+
# We use .fetch() here to get the element without clicking it yet
588+
menu_item = self.context_menu.fetch("context-menu-toolbar-open-in-new-tab")
589+
590+
# Use ActionChains to perform a more reliable click
591+
actions = ActionChains(self.driver)
592+
actions.move_to_element(menu_item).click().perform()
593+
594+
return self
595+
572596
@BasePage.context_chrome
573597
def open_bookmark_in_new_window_via_context_menu(
574598
self, bookmark_title: str

modules/data/context_menu.components.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@
115115
"groups": []
116116
},
117117

118+
"context-menu-toolbar-open-in-new-tab": {
119+
"selectorData": "placesContext_open:newtab",
120+
"strategy": "id",
121+
"groups": ["doNotCache"]
122+
},
123+
118124
"context-menu-open-link-in-new-window": {
119125
"selectorData": "context-openlink",
120126
"strategy": "id",
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
from selenium.webdriver.support import expected_conditions as EC
4+
from selenium.webdriver.support.ui import WebDriverWait
5+
6+
from modules.browser_object import Navigation, TabBar
7+
from modules.page_object_generics import GenericPage
8+
9+
10+
@pytest.fixture()
11+
def test_case():
12+
return "134460"
13+
14+
15+
BOOKMARK_URL = "https://www.youtube.com/"
16+
BOOKMARK_TITLE = "YouTube"
17+
18+
19+
def test_open_bookmark_in_new_tab(driver: Firefox):
20+
"""
21+
C134460: Verify that New Tabs can be opened by right clicking and selecting new tab from the bookmarks.
22+
"""
23+
24+
# Instantiate objects
25+
nav = Navigation(driver)
26+
tabs = TabBar(driver)
27+
page = GenericPage(driver, url=BOOKMARK_URL)
28+
29+
# Bookmark the test page via star button
30+
page.open()
31+
nav.add_bookmark_via_star_icon()
32+
33+
# In a new tab, right-click the bookmarked page in the toolbar and select Open in New Tab from the context menu
34+
tabs.new_tab_by_button()
35+
nav.open_bookmark_in_new_tab_via_context_menu(BOOKMARK_TITLE)
36+
37+
# Verify that the test page is opened in a new normal tab
38+
tabs.wait_for_num_tabs(3)
39+
driver.switch_to.window(driver.window_handles[-1])
40+
41+
WebDriverWait(driver, 5).until(EC.url_contains("youtube"))
42+
assert "youtube" in driver.current_url
43+
page.url_contains("youtube")

0 commit comments

Comments
 (0)