Skip to content

Commit 1729993

Browse files
Hani YacoubHani Yacoub
authored andcommitted
Merge remote-tracking branch 'refs/remotes/origin/main' into hy/preferences_all_toggles_enabled
# Conflicts: # modules/data/navigation.components.json
2 parents 81c57e9 + 678fa03 commit 1729993

File tree

6 files changed

+185
-7
lines changed

6 files changed

+185
-7
lines changed

modules/browser_object_navigation.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,32 @@ def search_bar_search(self, term: str) -> BasePage:
121121
self.search_bar.send_keys(term + Keys.ENTER)
122122
return self
123123

124+
def type_in_search_bar(self, term: str) -> BasePage:
125+
"""
126+
Type in the *Old* Search Bar. Returns self.
127+
128+
Attributes
129+
----------
130+
131+
term : str
132+
The search term
133+
"""
134+
with self.driver.context(self.driver.CONTEXT_CHROME):
135+
self.search_bar = self.find_element(By.CLASS_NAME, "searchbar-textbox")
136+
self.search_bar.click()
137+
self.search_bar.send_keys(term)
138+
return self
139+
140+
def click_on_change_search_settings_button(self) -> BasePage:
141+
with self.driver.context(self.driver.CONTEXT_CHROME):
142+
self.search_bar = self.find_element(By.CLASS_NAME, "searchbar-textbox")
143+
self.search_bar.click()
144+
self.change_search_settings_button = self.find_element(
145+
By.ID, "searchbar-anon-search-settings"
146+
)
147+
self.change_search_settings_button.click()
148+
return self
149+
124150
def click_in_awesome_bar(self) -> BasePage:
125151
self.set_awesome_bar()
126152
self.awesome_bar.click()

modules/browser_object_panel_ui.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ def navigate_to_about_addons(self):
6666
with self.driver.context(self.driver.CONTEXT_CHROME):
6767
self.get_element("manage-themes").click()
6868

69+
def navigate_to_customize_toolbar(self):
70+
"""
71+
On the hamburger menu > More Tools > Customize Toolbar
72+
"""
73+
self.select_panel_setting("more-tools")
74+
self.select_panel_setting("customize-toolbar")
75+
6976
def click_sync_sign_in_button(self) -> BasePage:
7077
"""
7178
Click FxA sync button.

modules/data/navigation.components.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,21 @@
168168
"groups": []
169169
},
170170

171-
"sponsored-site-card": {
172-
"selectorData": "top-site-outer",
173-
"strategy": "class",
171+
"firefox-suggest": {
172+
"selectorData": "div.urlbarView-row[label=\"Firefox Suggest\"] > span.urlbarView-row-inner",
173+
"strategy": "css",
174+
"groups": []
175+
},
176+
177+
"search-result-autofill-adaptive-element": {
178+
"selectorData": ".//*[@type='autofill_adaptive']",
179+
"strategy": "xpath",
174180
"groups": []
175181
},
176182

177-
"firefox-suggest": {
178-
"selectorData": "div[label='Firefox Suggest'] > span.urlbarView-row-inner, div[label='Firefox Suggest'] + div.urlbarView-row",
179-
"strategy": "css",
183+
"sponsored-site-card": {
184+
"selectorData": "top-site-outer",
185+
"strategy": "class",
180186
"groups": []
181187
},
182188

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
from selenium.webdriver.support import expected_conditions as EC
4+
from selenium.webdriver.support.wait import WebDriverWait
5+
6+
from modules.browser_object import Navigation
7+
from modules.browser_object_tabbar import TabBar
8+
9+
10+
@pytest.fixture()
11+
def add_prefs():
12+
return [
13+
("browser.search.region", "US"),
14+
("browser.urlbar.autoFill.adaptiveHistory.enabled", True),
15+
]
16+
17+
18+
def test_add_adaptive_history_autofill(driver: Firefox):
19+
"""
20+
C1814373 - Test to verify that typing the first three characters of a previously visited URL in the address bar
21+
triggers the adaptive history autofill.
22+
"""
23+
24+
nav = Navigation(driver).open()
25+
tabs = TabBar(driver)
26+
27+
nav.search("https://www.nationalgeographic.com/science/")
28+
WebDriverWait(driver, 10).until(
29+
lambda d: tabs.get_tab_title(tabs.get_tab(1)) == "Science"
30+
)
31+
32+
tabs.new_tab_by_button()
33+
tabs.wait_for_num_tabs(2)
34+
driver.switch_to.window(driver.window_handles[1])
35+
36+
with driver.context(driver.CONTEXT_CHROME):
37+
x_icon = tabs.get_element("tab-x-icon", multiple=True)
38+
x_icon[0].click()
39+
40+
# Type the first 3 characters of the visited URL in the address bar and select the suggested URL
41+
nav.type_in_awesome_bar("nat")
42+
nav.get_element("firefox-suggest").click()
43+
nav.expect_in_content(
44+
EC.url_contains("https://www.nationalgeographic.com/science/")
45+
)
46+
47+
tabs.set_content_context()
48+
49+
# Open a new tab, type the first 3 characters of the visited URL
50+
tabs.new_tab_by_button()
51+
tabs.wait_for_num_tabs(2)
52+
driver.switch_to.window(driver.window_handles[-1])
53+
nav.type_in_awesome_bar("nat")
54+
55+
autofill_adaptive_element = nav.get_element(
56+
"search-result-autofill-adaptive-element"
57+
)
58+
59+
# Assertion to verify that the 'autofill_adaptive' type is found
60+
assert (
61+
autofill_adaptive_element.get_attribute("type") == "autofill_adaptive"
62+
), f"Expected element type to be 'autofill_adaptive' but found '{autofill_adaptive_element.get_attribute('type')}'"
63+
64+
# Assertion to check the autofilled URL is the expected one
65+
assert (
66+
"nationalgeographic.com/science" in autofill_adaptive_element.text
67+
), "URL 'https://www.nationalgeographic.com/science' not found in autofill suggestions."
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
from time import sleep
2+
3+
import pytest
4+
from selenium.webdriver import Firefox
5+
from selenium.webdriver.common.by import By
6+
from selenium.webdriver.common.keys import Keys
7+
from selenium.webdriver.support import expected_conditions as EC
8+
from selenium.webdriver.support.wait import WebDriverWait
9+
10+
from modules.browser_object import Navigation
11+
from modules.browser_object_context_menu import ContextMenu
12+
from modules.page_object import AboutConfig, AboutPrefs
13+
14+
15+
@pytest.fixture()
16+
def add_prefs():
17+
return [
18+
("browser.search.region", "US"),
19+
]
20+
21+
22+
def test_default_search_provider_change(driver: Firefox):
23+
"""
24+
C1365245 - This test makes sure that the default search
25+
provider can be changed and settings are applied
26+
"""
27+
28+
# Create objects
29+
nav = Navigation(driver).open()
30+
about_config = AboutConfig(driver)
31+
search_term = "what is life?"
32+
33+
# enable search bar via about:config
34+
pref = "browser.search.widget.inNavBar"
35+
about_config.toggle_true_false_config(pref)
36+
nav.clear_awesome_bar()
37+
nav.set_content_context()
38+
sleep(1)
39+
40+
# type some word->select 'Change search settings' when the search drop-down panel is opened.
41+
42+
nav.type_in_search_bar(search_term)
43+
nav.click_on_change_search_settings_button()
44+
45+
# switch to the second tab
46+
driver.switch_to.window(driver.window_handles[1])
47+
sleep(1)
48+
49+
# check that the current URL is about:preferences#search
50+
assert driver.current_url == "about:preferences#search"
51+
52+
# open a site, open search settings again and check if it's opened in a different tab
53+
driver.get("https://9gag.com/")
54+
nav.type_in_search_bar(search_term)
55+
nav.click_on_change_search_settings_button()
56+
assert driver.current_url == "https://9gag.com/"
57+
58+
driver.switch_to.window(driver.window_handles[2])
59+
assert driver.current_url == "about:preferences#search"
60+
61+
# Set a different provider as a default search engine
62+
about_prefs = AboutPrefs(driver, category="search").open()
63+
about_prefs.search_engine_dropdown().select_option("DuckDuckGo")
64+
65+
# Open the search bar and type in a keyword and check if it's with the right provider
66+
nav.type_in_search_bar(search_term)
67+
with driver.context(driver.CONTEXT_CHROME):
68+
search_engine_name_element = driver.find_element(
69+
By.CSS_SELECTOR, ".searchbar-engine-name"
70+
)
71+
72+
assert search_engine_name_element.get_attribute("value") == "DuckDuckGo Search"

tests/theme_and_toolbar/test_customize_themes_and_redirect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_redirect_to_addons(driver: Firefox):
2828
@pytest.mark.parametrize("theme_name", list(themes.keys()))
2929
def test_open_addons(driver: Firefox, theme_name: str):
3030
"""
31-
C118173, continutation ensures that all the themes are set correctly
31+
C118173, continuation ensures that all the themes are set correctly
3232
"""
3333
nav = Navigation(driver).open()
3434
abt_addons = AboutAddons(driver).open()

0 commit comments

Comments
 (0)