Skip to content

Commit 26ec232

Browse files
authored
test: Created test to verify selected tabs can be pinned/unpinned (#845)
* test: Created test to verify selected tabs can be pinned/unpinned * Made requested changes to pin and unpin selected tabs test
1 parent 7f004f6 commit 26ec232

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

modules/browser_object_tabbar.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,3 +341,41 @@ def verify_tab_focus_cycle(self, num_tabs: int):
341341
self.custom_wait(timeout=3).until(
342342
lambda d: target_tab.get_attribute("visuallyselected") == ""
343343
)
344+
345+
@BasePage.context_chrome
346+
def select_multiple_tabs_by_indices(
347+
self, indices: list[int], sys_platform: str
348+
) -> list[WebElement]:
349+
"""
350+
Selects multiple tabs based on their indices and returns list of tabs.
351+
352+
Preconditions:
353+
- len(indices) > 1
354+
- max(indices) < number of open tabs
355+
- min(indices) >= 1
356+
Notes:
357+
- Opens (clicks) the tab at the first index in indices
358+
- the first tab in the window is denoted by index 1 (1-based indexing)
359+
"""
360+
361+
start_tab = self.get_tab(indices[0])
362+
selected_tabs = [start_tab]
363+
start_tab.click()
364+
365+
actions = self.actions
366+
if sys_platform == "Darwin":
367+
actions.key_down(Keys.COMMAND).perform()
368+
else:
369+
actions.key_down(Keys.CONTROL).perform()
370+
371+
for i in range(1, len(indices)):
372+
tab = self.get_tab(indices[i])
373+
actions.click(tab).perform()
374+
selected_tabs.append(tab)
375+
376+
if sys_platform == "Darwin":
377+
actions.key_up(Keys.COMMAND).perform()
378+
else:
379+
actions.key_up(Keys.CONTROL).perform()
380+
381+
return selected_tabs
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
select_indices = [1, 3, 5]
34+
selected_tabs = tabs.select_multiple_tabs_by_indices(select_indices, sys_platform)
35+
tab_context_menu = ContextMenu(driver)
36+
37+
# Pin
38+
tab_context_menu.context_click(selected_tabs[1])
39+
tab_context_menu.click_and_hide_menu(("css selector", "#context_pinSelectedTabs"))
40+
41+
# Verify pinned
42+
for tab in selected_tabs:
43+
assert tabs.is_pinned(tab)
44+
45+
# Unpin
46+
tab_context_menu.context_click(selected_tabs[1])
47+
tab_context_menu.click_and_hide_menu(("css selector", "#context_unpinSelectedTabs"))
48+
49+
# Verify unpinned
50+
for tab in selected_tabs:
51+
assert not tabs.is_pinned(tab)

0 commit comments

Comments
 (0)