Skip to content

Commit 678fa03

Browse files
Merge pull request #96 from mozilla/vs/test_default_search_provide_can_be_changed
Vs/test default search provider can be changed
2 parents 8570e4e + 4dcb9ef commit 678fa03

File tree

4 files changed

+106
-1
lines changed

4 files changed

+106
-1
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.
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)