Skip to content

Commit 89a7a4e

Browse files
vs/search-suggestions-private-windows (#866)
* vs/search-suggestions-private-windows
1 parent 3f7f0eb commit 89a7a4e

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

modules/browser_object_navigation.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,31 @@ def awesome_bar_has_suggestions(self) -> bool:
321321
suggestions = self.get_all_children("results-dropdown")
322322
return len(suggestions) > 2
323323

324+
def verify_no_external_suggestions(
325+
self,
326+
text: str | None = None,
327+
search_mode: str = "awesome",
328+
max_rows: int = 3,
329+
type_delay: float = 0.3,
330+
) -> bool:
331+
if search_mode == "awesome":
332+
if text is not None:
333+
self.clear_awesome_bar()
334+
self.type_in_awesome_bar(text)
335+
time.sleep(type_delay) # allow dropdown to update
336+
337+
suggestions = self.get_all_children("results-dropdown")
338+
return len(suggestions) <= max_rows
339+
340+
elif search_mode == "search":
341+
if text is not None:
342+
self.set_search_bar()
343+
self.type_in_search_bar(text)
344+
return not self.search_bar_has_suggestions(min_suggestions=1)
345+
346+
else:
347+
raise ValueError("search_mode must be either 'awesome' or 'search'")
348+
324349
@BasePage.context_chrome
325350
def search_bar_has_suggestions(self, min_suggestions: int = 0) -> bool:
326351
"""Check if the legacy search bar has suggestions. if a style has max-height: 0px, then no suggestions are present."""
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
4+
from modules.browser_object import Navigation
5+
from modules.browser_object_panel_ui import PanelUi
6+
7+
8+
@pytest.fixture()
9+
def test_case():
10+
return "3028799"
11+
12+
13+
SEARCH_ENGINES = [
14+
"@google",
15+
"@bing",
16+
"@duckduckgo",
17+
"@wikipedia",
18+
]
19+
20+
21+
@pytest.mark.smoke
22+
def test_no_search_engine_suggestions_in_private_window(driver: Firefox):
23+
"""
24+
C3028799 - Verify that in a New Private Window, after selecting a search shortcut,
25+
suggestions from that search engine are NOT displayed while typing a query.
26+
"""
27+
# Open Private Window
28+
panel = PanelUi(driver)
29+
panel.open_and_switch_to_new_window("private")
30+
31+
nav = Navigation(driver)
32+
33+
for shortcut in SEARCH_ENGINES:
34+
# Open a new tab for each shortcut
35+
nav.open_and_switch_to_new_window("tab")
36+
37+
# Activate search mode for the current engine
38+
nav.clear_awesome_bar()
39+
nav.search(shortcut)
40+
41+
# Type a query and verify that no external search suggestions appear
42+
has_no_external_suggestions = nav.verify_no_external_suggestions(
43+
text="random",
44+
search_mode="awesome",
45+
max_rows=3, # allow small internal items like history/bookmarks
46+
)
47+
48+
assert has_no_external_suggestions, (
49+
f"External search suggestions appeared for {shortcut} in Private Window."
50+
)
51+
52+
nav.clear_awesome_bar()

0 commit comments

Comments
 (0)