Skip to content

Commit 9b3f4c5

Browse files
vs/test-switch-to-tab (#907)
* vs/test-disable * vs/test-stt * vs/add-to-yaml * vs/add-to-navigation * vs/add-to-navigation * vs/add-to-navigation * vs/finishing touch
1 parent c2cda5e commit 9b3f4c5

File tree

7 files changed

+79
-0
lines changed

7 files changed

+79
-0
lines changed

SELECTOR_INFO.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3301,6 +3301,13 @@ Description: Exit button searchmode
33013301
Location: Address bar searchmode
33023302
Path to .json: modules/data/navigation.components.json
33033303
```
3304+
```
3305+
Selector Name: switch-to-tab
3306+
Selector Data: div.urlbarView-row[type='switchtab']
3307+
Description: Switch to tab from awesome bar
3308+
Location: Address bar
3309+
Path to .json: modules/data/navigation.components.json
3310+
```
33043311
#### panel_ui
33053312
```
33063313
Selector name: panel-ui-button

manifests/all.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ address_bar_and_search:
4040
- test_addon_suggestion
4141
- test_search_code_google_us
4242
- test_searchmode_cleared_on_engine_removal
43+
- test_switch_to_existing_tab_when_having_the_same_URL
4344
- test_search_suggestions
4445
- test_delete_history_entry_via_firefox_suggest_completion_list
4546
audio_video:

manifests/functional.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ address_bar_and_search:
66
- test_ctrl_enter_completes_link_and_can_refresh
77
- test_disable_websearch_from_awesome_bar
88
- test_searchmode_cleared_on_engine_removal
9+
- test_switch_to_existing_tab_when_having_the_same_URL
910
- test_delete_history_entry_via_firefox_suggest_completion_list
11+
1012
tabs:
1113
- test_change_position_of_pinned_tabs
1214
- test_close_pinned_tab_via_mouse

manifests/key.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ address_bar_and_search:
4545
test_server_not_found_error: pass
4646
test_server_not_found_error_pb: pass
4747
test_suggestion_engine_selection: pass
48+
test_switch_to_existing_tab_when_having_the_same_URL: pass
4849
test_tile_menu_options: pass
4950
test_use_different_search_shortcut_while_already_in_search_mode: pass
5051
test_verify_url_after_tab_switch_with_search_mode: pass

modules/browser_object_navigation.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,24 @@ def click_firefox_suggest(self) -> None:
123123
"""Click the Firefox suggested result."""
124124
self.get_element("firefox-suggest").click()
125125

126+
@BasePage.context_chrome
127+
def click_switch_to_tab(self) -> None:
128+
"""
129+
Clicks the 'Switch to Tab' suggestion in the URL bar results.
130+
Assumes the caller already typed into the awesome bar.
131+
132+
This uses a minimal wait that returns the list of matches only
133+
when at least one element is found.
134+
"""
135+
136+
# Wait until at least one switch-to-tab result is present
137+
switch_items = self.wait.until(
138+
lambda d: self.get_elements("switch-to-tab") or None
139+
)
140+
141+
# Click the first matching row
142+
switch_items[0].click()
143+
126144
@BasePage.context_chrome
127145
def search(self, term: str, mode=None) -> BasePage:
128146
"""

modules/data/navigation.components.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,12 @@
663663
"selectorData": "toolbarbutton[data-l10n-id='urlbar-searchmode-exit-button']",
664664
"strategy": "css",
665665
"groups": []
666+
},
667+
668+
"switch-to-tab": {
669+
"selectorData": "div.urlbarView-row[type='switchtab']",
670+
"strategy": "css",
671+
"groups": ["doNotCache"]
666672
}
667673

668674
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
4+
from modules.browser_object import Navigation
5+
from modules.browser_object_tabbar import TabBar
6+
7+
TEST_URL = "https://example.com"
8+
SITE_HOST = "example.com"
9+
10+
11+
@pytest.fixture()
12+
def test_case():
13+
return "3028949"
14+
15+
16+
def test_switch_to_existing_tab_when_having_the_same_URL(driver: Firefox):
17+
"""
18+
3028949 - Handle switch to tab functionality
19+
"""
20+
nav = Navigation(driver)
21+
tabs = TabBar(driver)
22+
23+
# Step 1: Open the first website
24+
driver.get(TEST_URL)
25+
26+
# Step 2: Open a new tab and switch to it
27+
tabs.new_tab_by_button()
28+
tabs.wait_for_num_tabs(2)
29+
tabs.switch_to_new_tab()
30+
31+
# Step 3: Type same URL into Awesome Bar
32+
nav.clear_awesome_bar()
33+
nav.type_in_awesome_bar(SITE_HOST)
34+
35+
# Step 4: Click "Switch to Tab" suggestion
36+
nav.click_switch_to_tab()
37+
tabs.wait_for_num_tabs(1)
38+
39+
# Step 5: Reattach driver to the remaining tab
40+
handle = driver.window_handles[0]
41+
driver.switch_to.window(handle)
42+
43+
# Step 7: Verify the remaining tab is the original TEST_URL
44+
assert TEST_URL in driver.current_url

0 commit comments

Comments
 (0)