|
| 1 | +import pytest |
| 2 | +from selenium.webdriver import Firefox |
| 3 | +from selenium.webdriver.support import expected_conditions as EC |
| 4 | +from selenium.webdriver.support.wait import WebDriverWait |
| 5 | + |
| 6 | +from modules.browser_object import Navigation |
| 7 | +from modules.browser_object_tabbar import TabBar |
| 8 | + |
| 9 | + |
| 10 | +@pytest.fixture() |
| 11 | +def add_prefs(): |
| 12 | + return [ |
| 13 | + ("browser.search.region", "US"), |
| 14 | + ("browser.urlbar.autoFill.adaptiveHistory.enabled", True), |
| 15 | + ] |
| 16 | + |
| 17 | + |
| 18 | +def test_add_adaptive_history_autofill(driver: Firefox): |
| 19 | + """ |
| 20 | + C1814373 - Test to verify that typing the first three characters of a previously visited URL in the address bar |
| 21 | + triggers the adaptive history autofill. |
| 22 | + """ |
| 23 | + |
| 24 | + nav = Navigation(driver).open() |
| 25 | + tabs = TabBar(driver) |
| 26 | + |
| 27 | + nav.search("https://news.google.com/home?hl=en-US&gl=US&ceid=US:en") |
| 28 | + WebDriverWait(driver, 10).until( |
| 29 | + lambda d: tabs.get_tab_title(tabs.get_tab(1)) == "Google News" |
| 30 | + ) |
| 31 | + |
| 32 | + tabs.new_tab_by_button() |
| 33 | + tabs.wait_for_num_tabs(2) |
| 34 | + driver.switch_to.window(driver.window_handles[1]) |
| 35 | + |
| 36 | + with driver.context(driver.CONTEXT_CHROME): |
| 37 | + x_icon = tabs.get_element("tab-x-icon", multiple=True) |
| 38 | + x_icon[0].click() |
| 39 | + |
| 40 | + # 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") |
| 42 | + nav.get_element("firefox-suggest").click() |
| 43 | + nav.expect_in_content( |
| 44 | + EC.url_contains("https://news.google.com/home?hl=en-US&gl=US&ceid=US:en") |
| 45 | + ) |
| 46 | + |
| 47 | + # Open a new tab, type the first 3 characters of the visited URL and see that it is autofilled directly |
| 48 | + 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") |
| 52 | + ) |
0 commit comments