Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions SELECTOR_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3301,6 +3301,13 @@ Description: Exit button searchmode
Location: Address bar searchmode
Path to .json: modules/data/navigation.components.json
```
```
Selector Name: switch-to-tab
Selector Data: div.urlbarView-row[type='switchtab']
Description: Switch to tab from awesome bar
Location: Address bar
Path to .json: modules/data/navigation.components.json
```
#### panel_ui
```
Selector name: panel-ui-button
Expand Down
1 change: 1 addition & 0 deletions manifests/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ address_bar_and_search:
- test_addon_suggestion
- test_search_code_google_us
- test_searchmode_cleared_on_engine_removal
- test_switch_to_existing_tab_when_having_the_same_URL
- test_search_suggestions
audio_video:
- test_block_audio_video_functionality
Expand Down
1 change: 1 addition & 0 deletions manifests/functional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ address_bar_and_search:
- test_ctrl_enter_completes_link_and_can_refresh
- test_disable_websearch_from_awesome_bar
- test_searchmode_cleared_on_engine_removal
- test_switch_to_existing_tab_when_having_the_same_URL
tabs:
- test_change_position_of_pinned_tabs
- test_close_pinned_tab_via_mouse
Expand Down
1 change: 1 addition & 0 deletions manifests/key.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ address_bar_and_search:
test_server_not_found_error: pass
test_server_not_found_error_pb: pass
test_suggestion_engine_selection: pass
test_switch_to_existing_tab_when_having_the_same_URL: pass
test_tile_menu_options: pass
test_use_different_search_shortcut_while_already_in_search_mode: pass
test_verify_url_after_tab_switch_with_search_mode: pass
Expand Down
18 changes: 18 additions & 0 deletions modules/browser_object_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,24 @@ def click_firefox_suggest(self) -> None:
"""Click the Firefox suggested result."""
self.get_element("firefox-suggest").click()

@BasePage.context_chrome
def click_switch_to_tab(self) -> None:
"""
Clicks the 'Switch to Tab' suggestion in the URL bar results.
Assumes the caller already typed into the awesome bar.

This uses a minimal wait that returns the list of matches only
when at least one element is found.
"""

# Wait until at least one switch-to-tab result is present
switch_items = self.wait.until(
lambda d: self.get_elements("switch-to-tab") or None
)

# Click the first matching row
switch_items[0].click()

@BasePage.context_chrome
def search(self, term: str, mode=None) -> BasePage:
"""
Expand Down
6 changes: 6 additions & 0 deletions modules/data/navigation.components.json
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,12 @@
"selectorData": "toolbarbutton[data-l10n-id='urlbar-searchmode-exit-button']",
"strategy": "css",
"groups": []
},

"switch-to-tab": {
"selectorData": "div.urlbarView-row[type='switchtab']",
"strategy": "css",
"groups": ["doNotCache"]
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import pytest
from selenium.webdriver import Firefox

from modules.browser_object import Navigation
from modules.browser_object_tabbar import TabBar

TEST_URL = "https://example.com"
SITE_HOST = "example.com"


@pytest.fixture()
def test_case():
return "3028949"


def test_switch_to_existing_tab_when_having_the_same_URL(driver: Firefox):
"""
3028949 - Handle switch to tab functionality
"""
nav = Navigation(driver)
tabs = TabBar(driver)

# Step 1: Open the first website
driver.get(TEST_URL)

# Step 2: Open a new tab and switch to it
tabs.new_tab_by_button()
tabs.wait_for_num_tabs(2)
tabs.switch_to_new_tab()

# Step 3: Type same URL into Awesome Bar
nav.clear_awesome_bar()
nav.type_in_awesome_bar(SITE_HOST)

# Step 4: Click "Switch to Tab" suggestion
nav.click_switch_to_tab()
tabs.wait_for_num_tabs(1)

# Step 5: Reattach driver to the remaining tab
handle = driver.window_handles[0]
driver.switch_to.window(handle)

# Step 7: Verify the remaining tab is the original TEST_URL
assert TEST_URL in driver.current_url
Loading