Skip to content
25 changes: 25 additions & 0 deletions modules/browser_object_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,31 @@ def awesome_bar_has_suggestions(self) -> bool:
suggestions = self.get_all_children("results-dropdown")
return len(suggestions) > 2

def verify_no_external_suggestions(
self,
text: str | None = None,
search_mode: str = "awesome",
max_rows: int = 3,
type_delay: float = 0.3,
) -> bool:
if search_mode == "awesome":
if text is not None:
self.clear_awesome_bar()
self.type_in_awesome_bar(text)
time.sleep(type_delay) # allow dropdown to update

suggestions = self.get_all_children("results-dropdown")
return len(suggestions) <= max_rows

elif search_mode == "search":
if text is not None:
self.set_search_bar()
self.type_in_search_bar(text)
return not self.search_bar_has_suggestions(min_suggestions=1)

else:
raise ValueError("search_mode must be either 'awesome' or 'search'")

@BasePage.context_chrome
def search_bar_has_suggestions(self, min_suggestions: int = 0) -> bool:
"""Check if the legacy search bar has suggestions. if a style has max-height: 0px, then no suggestions are present."""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import pytest
from selenium.webdriver import Firefox

from modules.browser_object import Navigation
from modules.browser_object_panel_ui import PanelUi


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


SEARCH_ENGINES = [
"@google",
"@bing",
"@duckduckgo",
"@wikipedia",
]


@pytest.mark.smoke
def test_no_search_engine_suggestions_in_private_window(driver: Firefox):
"""
C3028799 - Verify that in a New Private Window, after selecting a search shortcut,
suggestions from that search engine are NOT displayed while typing a query.
"""
# Open Private Window
panel = PanelUi(driver)
panel.open_and_switch_to_new_window("private")

nav = Navigation(driver)

for shortcut in SEARCH_ENGINES:
# Open a new tab for each shortcut
nav.open_and_switch_to_new_window("tab")

# Activate search mode for the current engine
nav.clear_awesome_bar()
nav.search(shortcut)

# Type a query and verify that no external search suggestions appear
has_no_external_suggestions = nav.verify_no_external_suggestions(
text="random",
search_mode="awesome",
max_rows=3, # allow small internal items like history/bookmarks
)

assert has_no_external_suggestions, (
f"External search suggestions appeared for {shortcut} in Private Window."
)

nav.clear_awesome_bar()