@@ -20,6 +20,7 @@ def add_prefs():
20
20
FIRST_RESULT = "https://www.google.com/search?client=firefox-b-1-d&q=cheetah"
21
21
SECOND_SEARCH = "lion"
22
22
SECOND_RESULT = "https://www.google.com/search?client=firefox-b-1-d&q=lion"
23
+ SEARCH_BAR_PREF = "browser.search.widget.inNavBar"
23
24
24
25
25
26
def test_search_term_persists (driver : Firefox ):
@@ -31,13 +32,16 @@ def test_search_term_persists(driver: Firefox):
31
32
nav = Navigation (driver ).open ()
32
33
tab = TabBar (driver )
33
34
34
- def toggle_old_search_bar ():
35
+ def toggle_legacy_search_bar ():
36
+ # This test requires that the old search bar is added while retaining search results.
37
+ # First, open a new tab and switch to it
35
38
tab .new_tab_by_button ()
36
39
window_handles = driver .window_handles
37
40
driver .switch_to .window (window_handles [- 1 ])
41
+ # Then, toggle the old search bar via about:config
38
42
ac = AboutConfig (driver )
39
- pref = "browser.search.widget.inNavBar"
40
- ac . toggle_true_false_config ( pref )
43
+ ac . toggle_true_false_config ( SEARCH_BAR_PREF )
44
+ # Finally, close the about:config tab and switch context back to the original tab
41
45
nav .set_chrome_context ()
42
46
x_icon = tab .get_element ("tab-x-icon" , multiple = True )
43
47
x_icon [1 ].click ()
@@ -47,14 +51,14 @@ def toggle_old_search_bar():
47
51
nav .search (FIRST_SEARCH )
48
52
tab .expect_title_contains ("Google Search" )
49
53
nav .set_chrome_context ()
50
- address_bar_text = nav .get_element ( "awesome-bar" ). get_attribute ( "value" )
54
+ address_bar_text = nav .get_awesome_bar_text ( )
51
55
assert FIRST_SEARCH == address_bar_text
52
56
53
57
# Add the search bar to toolbar
54
- toggle_old_search_bar ()
58
+ toggle_legacy_search_bar ()
55
59
56
60
# Search term should be replaced with full url
57
- address_bar_text = nav .get_element ( "awesome-bar" ). get_attribute ( "value" )
61
+ address_bar_text = nav .get_awesome_bar_text ( )
58
62
assert FIRST_RESULT == address_bar_text
59
63
nav .clear_awesome_bar ()
60
64
@@ -65,16 +69,15 @@ def toggle_old_search_bar():
65
69
# Then perform another search
66
70
nav .search (SECOND_SEARCH )
67
71
tab .expect_title_contains ("Google Search" )
68
- nav .set_chrome_context ()
69
- address_bar_text = nav .get_element ("awesome-bar" ).get_attribute ("value" )
72
+ address_bar_text = nav .get_awesome_bar_text ()
70
73
assert SECOND_RESULT == address_bar_text
71
74
72
75
# Disable the old search bar
73
- toggle_old_search_bar ()
76
+ toggle_legacy_search_bar ()
74
77
75
78
# Again, perform a search using the URL bar.
76
79
nav .search (FIRST_SEARCH )
77
80
tab .expect_title_contains ("Google Search" )
78
81
nav .set_chrome_context ()
79
- address_bar_text = nav .get_element ( "awesome-bar" ). get_attribute ( "value" )
82
+ address_bar_text = nav .get_awesome_bar_text ( )
80
83
assert FIRST_SEARCH == address_bar_text
0 commit comments