Skip to content

Commit 32ebed0

Browse files
committed
Redo the assertion
1 parent 199d953 commit 32ebed0

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

modules/data/navigation.components.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,11 @@
152152
"selectorData": "div.urlbarView-row[label=\"Firefox Suggest\"] > span.urlbarView-row-inner",
153153
"strategy": "css",
154154
"groups": []
155+
},
156+
157+
"search-result-autofill-adaptive-element": {
158+
"selectorData": ".//*[@type='autofill_adaptive']",
159+
"strategy": "xpath",
160+
"groups": []
155161
}
156162
}

tests/address_bar_and_search/test_adaptive_history_autofill.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ def test_add_adaptive_history_autofill(driver: Firefox):
2424
nav = Navigation(driver).open()
2525
tabs = TabBar(driver)
2626

27-
nav.search("https://news.google.com/home?hl=en-US&gl=US&ceid=US:en")
27+
nav.search("https://www.nationalgeographic.com/science/")
2828
WebDriverWait(driver, 10).until(
29-
lambda d: tabs.get_tab_title(tabs.get_tab(1)) == "Google News"
29+
lambda d: tabs.get_tab_title(tabs.get_tab(1)) == "Science"
3030
)
3131

3232
tabs.new_tab_by_button()
@@ -38,15 +38,27 @@ def test_add_adaptive_history_autofill(driver: Firefox):
3838
x_icon[0].click()
3939

4040
# Type the first 3 characters of the visited URL in the address bar and select the suggested URL
41-
nav.type_in_awesome_bar("new")
41+
nav.type_in_awesome_bar("nat")
4242
nav.get_element("firefox-suggest").click()
4343
nav.expect_in_content(
44-
EC.url_contains("https://news.google.com/home?hl=en-US&gl=US&ceid=US:en")
44+
EC.url_contains("https://www.nationalgeographic.com/science/")
4545
)
4646

47-
# Open a new tab, type the first 3 characters of the visited URL and see that it is autofilled directly
47+
# Open a new tab, type the first 3 characters of the visited URL
4848
tabs.new_tab_by_button()
49-
nav.type_in_awesome_bar("new")
50-
nav.expect_in_content(
51-
EC.url_contains("https://news.google.com/home?hl=en-US&gl=US&ceid=US:en")
49+
driver.switch_to.window(driver.window_handles[-1])
50+
nav.type_in_awesome_bar("nat")
51+
52+
autofill_adaptive_element = nav.get_element(
53+
"search-result-autofill-adaptive-element"
5254
)
55+
56+
# Assertion to verify that the 'autofill_adaptive' type is found
57+
assert (
58+
autofill_adaptive_element.get_attribute("type") == "autofill_adaptive"
59+
), f"Expected element type to be 'autofill_adaptive' but found '{autofill_adaptive_element.get_attribute('type')}'"
60+
61+
# Assertion to check the autofilled URL is the expected one
62+
assert (
63+
"nationalgeographic.com/science" in autofill_adaptive_element.text
64+
), "URL 'https://www.nationalgeographic.com/science' not found in autofill suggestions."

0 commit comments

Comments
 (0)