Skip to content

Commit 6436bac

Browse files
committed
VS/test change default search provider
1 parent 49bd9fd commit 6436bac

File tree

4 files changed

+102
-1
lines changed

4 files changed

+102
-1
lines changed

modules/browser_object_navigation.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,30 @@ 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(By.ID, "searchbar-anon-search-settings")
145+
self.change_search_settings_button.click()
146+
return self
147+
124148
def click_in_awesome_bar(self) -> BasePage:
125149
self.set_awesome_bar()
126150
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.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import pytest
2+
from selenium.webdriver.common.by import By
3+
from selenium.webdriver.common.keys import Keys
4+
from selenium.webdriver import Firefox
5+
from selenium.webdriver.support import expected_conditions as EC
6+
from selenium.webdriver.support.wait import WebDriverWait
7+
from modules.page_object import AboutPrefs, AboutConfig
8+
9+
from modules.browser_object import Navigation
10+
from modules.browser_object_context_menu import ContextMenu
11+
from time import sleep
12+
13+
14+
@pytest.fixture()
15+
def add_prefs():
16+
return [
17+
("browser.search.region", "US"),
18+
]
19+
20+
def test_default_search_provider_change(driver: Firefox):
21+
"""
22+
C1365245 - This test makes sure that the default search
23+
provider can be changed and settings are applied
24+
"""
25+
26+
# Create objects
27+
nav = Navigation(driver).open()
28+
about_config = AboutConfig(driver)
29+
search_term = "what is life?"
30+
31+
# enable search bar via about:config
32+
#about_config.change_pref_value("cookiebanners.service.mode", 1)
33+
pref = "browser.search.widget.inNavBar"
34+
about_config.toggle_true_false_config(pref)
35+
nav.clear_awesome_bar()
36+
nav.set_content_context()
37+
sleep(1)
38+
39+
# type some word->select 'Change search settings' when the search drop-down panel is opened.
40+
41+
nav.type_in_search_bar(search_term)
42+
nav.click_on_change_search_settings_button()
43+
44+
# switch to the second tab
45+
driver.switch_to.window(driver.window_handles[1])
46+
sleep(1)
47+
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+
search_engine_name_element = driver.find_element(By.CSS_SELECTOR, '.searchbar-engine-name')
68+
69+
assert search_engine_name_element.text == "DuckDuckGo"
70+
sleep(4)

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)