Skip to content

Commit d0987ab

Browse files
committed
vs/add-to-navigation
1 parent 8549407 commit d0987ab

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

manifests/incident.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ address_bar_and_search:
1212
- test_search_term_persists
1313
- test_server_not_found_error
1414
- test_suggestion_engine_selection
15-
- test_switch_to_existing_tab_when_having_the_same_URL
1615
audio_video:
1716
- test_allow_audio_video_functionality
1817
- test_block_audio_video_functionality

manifests/smoke.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ address_bar_and_search:
3333
- test_server_not_found_error
3434
- test_server_not_found_error_pb
3535
- test_suggestion_engine_selection
36-
- test_switch_to_existing_tab_when_having_the_same_URL
3736
- test_tile_menu_options
3837
audio_video:
3938
- test_allow_audio_video_functionality

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+
def click_switch_to_tab(self) -> None:
127+
"""
128+
Clicks the 'Switch to Tab' suggestion in the URL bar results.
129+
Assumes the caller already typed into the awesome bar.
130+
131+
This uses a minimal wait that returns the list of matches only
132+
when at least one element is found.
133+
"""
134+
135+
with self.driver.context(self.driver.CONTEXT_CHROME):
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
"""

tests/address_bar_and_search/test_switch_to_existing_tab_when_having_the_same_URL.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ def test_case():
1313
return "3028949"
1414

1515

16-
@pytest.mark.functional
1716
def test_switch_to_existing_tab_when_having_the_same_URL(driver: Firefox):
1817
"""
1918
3028949 - Handle switch to tab functionality
@@ -33,17 +32,15 @@ def test_switch_to_existing_tab_when_having_the_same_URL(driver: Firefox):
3332
nav.clear_awesome_bar()
3433
nav.type_in_awesome_bar(SITE_HOST)
3534

36-
# Step 4–5: Find AND CLICK "Switch to Tab" in chrome context
37-
with driver.context(driver.CONTEXT_CHROME):
38-
nav.wait.until(lambda d: len(nav.get_elements("switch-to-tab")) > 0)
39-
switch_row = nav.get_elements("switch-to-tab")[0]
40-
switch_row.click()
35+
# Step 4: Click "Switch to Tab" suggestion
36+
nav.click_switch_to_tab()
4137

42-
# Step 6: After clicking, the new tab's context is discarded.
43-
# Re-attach to the remaining tab and assert we only have one.
38+
# Step 5: Wait until only one tab remains
4439
tabs.wait_for_num_tabs(1)
45-
remaining_handles = driver.window_handles
46-
assert len(remaining_handles) == 1
4740

48-
driver.switch_to.window(remaining_handles[0])
41+
# Step 6: Reattach driver to the remaining tab
42+
handle = driver.window_handles[0]
43+
driver.switch_to.window(handle)
44+
45+
# Step 7: Verify the remaining tab is the original TEST_URL
4946
assert TEST_URL in driver.current_url

0 commit comments

Comments
 (0)