Skip to content

Commit bc4b7eb

Browse files
sv-hyacoubHani Yacoub
andauthored
Hani/test addressbar bookmarks when history disabled (#925)
* Test addressbar bookmarks when history disabled * add .ymal * edit methods * one method instead of two * remove all.ymal and functional.ymal --------- Co-authored-by: Hani Yacoub <[email protected]>
1 parent 93bf674 commit bc4b7eb

File tree

6 files changed

+116
-1
lines changed

6 files changed

+116
-1
lines changed

SELECTOR_INFO.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,13 @@ Description: The Restore Default Search Engines button under Search shortcuts ta
12431243
Location: about:preferences#search Search Shortcuts subsection
12441244
Path to .json: modules/data/about_prefs.components.json
12451245
```
1246+
```
1247+
Selector Name: Browsing History
1248+
Selector Data: history-suggestion
1249+
Description: Browsing History / History Suggestion under Address bar section
1250+
Location: about:preferences#search
1251+
Path to .json: modules/data/about_prefs.components.json
1252+
```
12461253
#### about_profiles
12471254
```
12481255
Selector Name: profile-container

manifests/key.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ address_bar_and_search:
2020
splits:
2121
- smoke
2222
- ci-extended
23+
test_addressbar_bookmarks_when_history_disabled:
24+
result: pass
25+
splits:
26+
- functional1
2327
test_addressbar_search_engine_keywords:
2428
result: pass
2529
splits:

modules/browser_object_navigation.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,3 +1085,48 @@ def click_exit_button_searchmode(self) -> None:
10851085

10861086
# Click the button
10871087
self.get_element("exit-button-searchmode").click()
1088+
1089+
@BasePage.context_chrome
1090+
def type_and_verify(
1091+
self,
1092+
input_text: str,
1093+
expected_text: str,
1094+
timeout: float = 5.0,
1095+
click: bool = True, # If True: click match; else: return index
1096+
) -> int | bool:
1097+
"""
1098+
Types into the awesome bar, waits for a suggestion containing `expected_text`.
1099+
1100+
If `click=True` (default):
1101+
- Click the matching element and return True
1102+
- Raises if not found (test fails)
1103+
1104+
If `click=False`:
1105+
- Return the 0-based index of the matching element
1106+
- Raises if not found (test fails)
1107+
"""
1108+
1109+
# Reset + type
1110+
self.clear_awesome_bar()
1111+
self.type_in_awesome_bar(input_text)
1112+
1113+
def find_match(driver):
1114+
suggestions = self.get_all_children("results-dropdown")
1115+
1116+
for index, s in enumerate(suggestions):
1117+
try:
1118+
if expected_text in s.text:
1119+
return (s, index)
1120+
except StaleElementReferenceException:
1121+
continue
1122+
1123+
return False # keep polling
1124+
1125+
# No try/except here — failure = real failure
1126+
element, index = self.custom_wait(timeout=timeout).until(find_match)
1127+
1128+
if click:
1129+
element.click()
1130+
return True
1131+
1132+
return index

modules/data/about_prefs.components.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,10 @@
612612
"groups": [
613613
"doNotCache"
614614
]
615+
},
616+
"history-suggestion": {
617+
"selectorData": "historySuggestion",
618+
"strategy": "id",
619+
"groups": []
615620
}
616-
617621
}

modules/page_object_prefs.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,14 @@ def open_manage_cookies_data_dialog(self) -> BasePage:
805805
BrowserActions(self.driver).switch_to_iframe_context(manage_data_popup)
806806
return self
807807

808+
def uncheck_history_suggestion(self):
809+
"""
810+
Uncheck the 'historySuggestion' checkbox if it's currently checked.
811+
"""
812+
checkbox = self.get_element("history-suggestion")
813+
if checkbox.is_selected():
814+
checkbox.click()
815+
808816

809817
class AboutAddons(BasePage):
810818
"""
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
4+
from modules.browser_object_navigation import Navigation
5+
from modules.browser_object_tabbar import TabBar
6+
from modules.page_object_prefs import AboutPrefs
7+
8+
9+
@pytest.fixture()
10+
def test_case():
11+
return "3028908"
12+
13+
14+
def test_addressbar_bookmarks_when_history_disabled(driver: Firefox):
15+
"""
16+
C3028908 - Most relevant bookmarks are shown in the address bar even when history is disabled
17+
"""
18+
19+
# Instantiate objects
20+
nav = Navigation(driver)
21+
tabs = TabBar(driver)
22+
about_prefs = AboutPrefs(driver, category="search")
23+
24+
# In addressbar press z and pick "Get Involved" page
25+
nav.type_and_verify("z", "Get Involved", click=True)
26+
27+
# Repeat step from above
28+
tabs.new_tab_by_button()
29+
nav.type_and_verify("z", "Get Involved", click=True)
30+
31+
# On z press check "Get Involved" page is shown as the first result
32+
tabs.new_tab_by_button()
33+
position = nav.type_and_verify("z", "Get Involved", click=False)
34+
assert position == 1
35+
36+
# Navigate to about:preferences and uncheck Browsing History
37+
tabs.new_tab_by_button()
38+
driver.switch_to.window(driver.window_handles[-1])
39+
about_prefs.open()
40+
about_prefs.uncheck_history_suggestion()
41+
42+
# Open a new tab and press z
43+
tabs.new_tab_by_button()
44+
45+
# Check "Get Involved" page is shown as the first result
46+
position = nav.type_and_verify("z", "Get Involved", click=False)
47+
assert position == 1

0 commit comments

Comments
 (0)