Skip to content

Commit 61dd689

Browse files
committed
test: Created test to verify selected tabs can be pinned/unpinned
1 parent 8ecec12 commit 61dd689

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

modules/browser_object_tabbar.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,41 @@ def verify_tab_focus_cycle(self, num_tabs: int):
326326
self.custom_wait(timeout=3).until(
327327
lambda d: target_tab.get_attribute("visuallyselected") == ""
328328
)
329+
330+
@BasePage.context_chrome
331+
def select_tabs_by_indices(
332+
self, indices: list[int], sys_platform: str
333+
) -> list[WebElement]:
334+
"""
335+
Selects multiple tabs based on their indices and returns list of tabs.
336+
337+
Preconditions:
338+
- len(indices) > 1
339+
- max(indices) < number of open tabs
340+
- min(indices) >= 1
341+
Notes:
342+
- Opens (clicks) the tab at the first index in indices
343+
- the first tab in the window is denoted by index 1 (1-based indexing)
344+
"""
345+
346+
start_tab = self.get_tab(indices[0])
347+
selected_tabs = [start_tab]
348+
start_tab.click()
349+
350+
actions = self.actions
351+
if sys_platform == "Darwin":
352+
actions.key_down(Keys.COMMAND).perform()
353+
else:
354+
actions.key_down(Keys.CONTROL).perform()
355+
356+
for i in range(1, len(indices)):
357+
tab = self.get_tab(indices[i])
358+
actions.click(tab).perform()
359+
selected_tabs.append(tab)
360+
361+
if sys_platform == "Darwin":
362+
actions.key_up(Keys.COMMAND).perform()
363+
else:
364+
actions.key_up(Keys.CONTROL).perform()
365+
366+
return selected_tabs
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
4+
from modules.browser_object import ContextMenu, TabBar
5+
6+
7+
@pytest.fixture()
8+
def test_case():
9+
return "246978"
10+
11+
12+
URLS = [
13+
"about:about",
14+
"about:addons",
15+
"about:cache",
16+
"about:robots",
17+
]
18+
19+
20+
def test_pin_unpin_selected_tabs(driver: Firefox, sys_platform: str):
21+
"""
22+
C246978 - Verify that multiple tabs can be selected and pinned/unpinned from the context menu.
23+
"""
24+
25+
tabs = TabBar(driver)
26+
# Create 4 new tabs
27+
for i in range(4):
28+
tabs.new_tab_by_button()
29+
driver.switch_to.window(driver.window_handles[-1])
30+
driver.get(URLS[i])
31+
assert len(driver.window_handles) == 5
32+
33+
with driver.context(driver.CONTEXT_CHROME):
34+
select_indices = [1, 3, 5]
35+
selected_tabs = tabs.select_tabs_by_indices(select_indices, sys_platform)
36+
tab_context_menu = ContextMenu(driver)
37+
38+
# Pin
39+
tab_context_menu.context_click(selected_tabs[1])
40+
tab_context_menu.click_and_hide_menu(
41+
("css selector", "#context_pinSelectedTabs")
42+
)
43+
44+
# Verify pinned
45+
for tab in selected_tabs:
46+
assert tabs.is_pinned(tab)
47+
48+
# Unpin
49+
tab_context_menu.context_click(selected_tabs[1])
50+
tab_context_menu.click_and_hide_menu(
51+
("css selector", "#context_unpinSelectedTabs")
52+
)
53+
54+
# Verify unpinned
55+
for tab in selected_tabs:
56+
assert not tabs.is_pinned(tab)

0 commit comments

Comments
 (0)