Skip to content

Commit c7def5b

Browse files
committed
Create test for persistence of search terms
1 parent 27d2008 commit c7def5b

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
from selenium.webdriver.support import expected_conditions as EC
4+
5+
from modules.browser_object import Navigation
6+
from modules.browser_object_tabbar import TabBar
7+
from modules.page_object import AboutConfig
8+
9+
10+
# Set search region
11+
@pytest.fixture()
12+
def add_prefs():
13+
return [
14+
("browser.search.region", "US"),
15+
("browser.urlbar.showSearchTerms.enabled", True),
16+
("browser.urlbar.showSearchTerms.featureGate", True),
17+
]
18+
19+
20+
def test_search_term_persists(driver: Firefox):
21+
"""
22+
C2153943 - Persist search term basic functionality
23+
"""
24+
25+
# Create objects
26+
nav = Navigation(driver).open()
27+
tab = TabBar(driver)
28+
29+
# Set values
30+
search1 = "cheetah"
31+
result1 = "https://www.google.com/search?client=firefox-b-1-d&q=cheetah"
32+
search2 = "lion"
33+
result2 = "https://www.google.com/search?client=firefox-b-1-d&q=lion"
34+
35+
def toggle_old_search_bar():
36+
tab.new_tab_by_button()
37+
window_handles = driver.window_handles
38+
driver.switch_to.window(window_handles[-1])
39+
ac = AboutConfig(driver)
40+
pref = "browser.search.widget.inNavBar"
41+
ac.toggle_true_false_config(pref)
42+
nav.set_chrome_context()
43+
x_icon = tab.get_element("tab-x-icon", multiple=True)
44+
x_icon[1].click()
45+
driver.switch_to.window(window_handles[0])
46+
47+
# Perform a search using the URL bar.
48+
nav.search(search1)
49+
nav.expect(EC.title_contains("Google Search"))
50+
nav.set_chrome_context()
51+
address_bar_text = nav.get_element("awesome-bar").get_attribute("value")
52+
print("address bar value: ", address_bar_text)
53+
assert search1 == address_bar_text
54+
55+
# Add the search bar to toolbar
56+
toggle_old_search_bar()
57+
58+
# Search term should be replaced with full url
59+
address_bar_text = nav.get_element("awesome-bar").get_attribute("value")
60+
print("address bar value: ", address_bar_text)
61+
assert result1 == address_bar_text
62+
nav.clear_awesome_bar()
63+
64+
# Perform a new awesome bar search, full url should be present
65+
# First, navigate away from Google
66+
nav.set_content_context()
67+
driver.get("about:robots")
68+
# Then perform another search
69+
nav.search(search2)
70+
nav.expect(EC.title_contains("Google Search"))
71+
nav.set_chrome_context()
72+
address_bar_text = nav.get_element("awesome-bar").get_attribute("value")
73+
print("address bar value: ", address_bar_text)
74+
assert result2 == address_bar_text
75+
76+
# Disable the old search bar
77+
toggle_old_search_bar()
78+
79+
# Again, perform a search using the URL bar.
80+
nav.search(search1)
81+
nav.expect(EC.title_contains("Google Search"))
82+
nav.set_chrome_context()
83+
address_bar_text = nav.get_element("awesome-bar").get_attribute("value")
84+
print("address bar value: ", address_bar_text)
85+
assert search1 == address_bar_text

0 commit comments

Comments
 (0)