Skip to content

Commit c6a97c9

Browse files
committed
2/3 test cases work
1 parent c1be62b commit c6a97c9

File tree

3 files changed

+105
-1
lines changed

3 files changed

+105
-1
lines changed

SELECTOR_INFO.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1888,6 +1888,20 @@ Location: Context menu - Tab
18881888
Path to .json: modules/data/context_menu.components.json
18891889
```
18901890
```
1891+
Selector Name: context-menu-move-tab-to-end
1892+
Selector Data: menuitem[data-l10n-id='move-to-end']
1893+
Description: Context menu option to move a tab to the end of the tab bar.
1894+
Location: Context menu - Tab
1895+
Path to .json: modules/data/context_menu.components.json
1896+
```
1897+
```
1898+
Selector Name: context-menu-move-to-new-window
1899+
Selector Data: menuitem[data-l10n-id='move-to-new-window']
1900+
Description: Context menu option to move a tab to a new window.
1901+
Location: Context menu - Tab
1902+
Path to .json: modules/data/context_menu.components.json
1903+
```
1904+
```
18911905
Selector Name: context-menu-bookmark-link
18921906
Selector Data: context-bookmarklink
18931907
Description: Context menu option to bookmark a link
@@ -1899,8 +1913,8 @@ Selector Name: context-menu-search-select
18991913
Selector Data: coontext-searchselect
19001914
Description: Context menu option to search selected text with the engine set as default
19011915
Location: Context menu - topsite context menu
1902-
Path to .json: modules/data/context_menu.components.json
19031916
```
1917+
19041918
#### credit_card_fill
19051919
```
19061920
Selector Name: form-field

modules/data/context_menu.components.json

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

118+
"context-menu-move-tab-to-end": {
119+
"selectorData": "menuitem[data-l10n-id='move-to-end']",
120+
"strategy": "css",
121+
"groups": []
122+
},
123+
124+
"context-menu-move-to-new-window": {
125+
"selectorData": "menuitem[data-l10n-id='move-to-new-window']",
126+
"strategy": "css",
127+
"groups": []
128+
},
129+
130+
118131
"context-menu-open-link-in-tab": {
119132
"selectorData": "context-openlinkintab",
120133
"strategy": "id",
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import logging
2+
import platform
3+
import time
4+
5+
import pytest
6+
from selenium.webdriver import ActionChains, Firefox, Keys
7+
from selenium.webdriver.common.by import By
8+
9+
from modules.browser_object import ContextMenu, TabBar
10+
11+
# Title Constants
12+
EXPECTED_MOZILLA_TITLE = "Mozilla"
13+
EXPECTED_ROBOT_TITLE = "Gort!"
14+
EXPECTED_WELCOME_TITLE = "Welcome"
15+
16+
MOVE_TO_END = "context-menu-move-tab-to-end"
17+
MOVE_TO_START = "context-menu-move-tab-to-start"
18+
MOVE_TO_NEW_WINDOW = "context-menu-move-to-new-window"
19+
20+
21+
@pytest.fixture()
22+
def test_case():
23+
return "246989"
24+
25+
26+
@pytest.mark.parametrize(
27+
"move_option,expected_title,expected_position",
28+
[
29+
(MOVE_TO_END, EXPECTED_ROBOT_TITLE, 2),
30+
(MOVE_TO_START, EXPECTED_ROBOT_TITLE, 0),
31+
# (MOVE_TO_NEW_WINDOW, EXPECTED_ROBOT_TITLE, 0),
32+
],
33+
)
34+
def test_move_multi_selected_tabs(
35+
driver: Firefox, sys_platform: str, move_option, expected_title, expected_position
36+
):
37+
"""Test all tab movement operations in separate test runs"""
38+
tab_movements(driver, sys_platform, move_option, expected_title, expected_position)
39+
40+
41+
def tab_movements(
42+
driver: Firefox, sys_platform: str, move_option, expected_title, expected_position
43+
): # expected_position starts at index 0
44+
tabs = TabBar(driver)
45+
tab_context_menu = ContextMenu(driver)
46+
original_windows = None
47+
48+
tab_titles = []
49+
url_list = ["https://mozilla.org", "about:robots", "about:welcome", "about:logo"]
50+
51+
driver.get(url_list[0])
52+
tab_titles.append(driver.title)
53+
54+
# Open 4 tabs
55+
for i in range(1, len(url_list)):
56+
tabs.new_tab_by_button()
57+
driver.switch_to.window(driver.window_handles[-1])
58+
driver.get(url_list[i])
59+
tab_titles.append(driver.title)
60+
61+
# Specific tabs we want to work with
62+
selected_tab_indices = [2, 3]
63+
selected_tabs = tabs.select_multiple_tabs_by_indices(
64+
selected_tab_indices, sys_platform
65+
)
66+
67+
# move-to-- -repeated
68+
tabs.context_click(selected_tabs[1])
69+
tab_context_menu.click_and_hide_menu(move_option)
70+
tabs.hide_popup("tabContextMenu")
71+
72+
# Verify for move-to-end/move-to-start
73+
driver.switch_to.window(driver.window_handles[expected_position])
74+
actual_title = driver.title
75+
assert expected_title in actual_title, (
76+
f"Expected '{expected_title}' at position {expected_position}"
77+
)

0 commit comments

Comments
 (0)