Skip to content

Commit d39c1a5

Browse files
committed
merge changes in
2 parents 05ae6f0 + 678fa03 commit d39c1a5

16 files changed

+360
-45
lines changed

conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ def driver(
177177
separator = " "
178178
winsize = [int(s) for s in opt_window_size.split(separator)]
179179
driver.set_window_size(*winsize)
180-
driver.implicitly_wait(opt_implicit_timeout)
180+
timeout = 30 if opt_ci else opt_implicit_timeout
181+
driver.implicitly_wait(timeout)
181182
yield driver
182183

183184
finally:

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: 31 additions & 1 deletion
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.
@@ -75,6 +82,15 @@ def click_sync_sign_in_button(self) -> BasePage:
7582
self.select_panel_setting("fxa-sign-in")
7683
return self
7784

85+
def log_out_fxa(self) -> BasePage:
86+
"""
87+
Click FxA signout button.
88+
"""
89+
with self.driver.context(self.driver.CONTEXT_CHROME):
90+
self.click_sync_sign_in_button()
91+
self.get_element("fxa-sign-out-button").click()
92+
return self
93+
7894
def manage_fxa_account(self) -> BasePage:
7995
"""
8096
Open the FxA management flow.
@@ -90,5 +106,19 @@ def confirm_sync_in_progress(self) -> BasePage:
90106
"""
91107
with self.driver.context(self.driver.CONTEXT_CHROME):
92108
self.click_sync_sign_in_button()
93-
self.element_has_text("fxa-sync-label", "Syncing")
109+
self.custom_wait(timeout=30, poll_frequency=0.5).until(
110+
EC.text_to_be_present_in_element(
111+
self.get_selector("fxa-sync-label"), "Syncing"
112+
)
113+
)
114+
return self
115+
116+
def start_sync(self) -> BasePage:
117+
"""
118+
Start FxA sync
119+
"""
120+
with self.driver.context(self.driver.CONTEXT_CHROME):
121+
self.click_sync_sign_in_button()
122+
self.element_has_text("fxa-sync-label", "Sync now")
123+
self.get_element("fxa-sync-label").click()
94124
return self

modules/data/fxa_new_account.components.json renamed to modules/data/fxa_home.components.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"groups": [
66
"requiredForPage"
77
]
8+
89
},
910

1011
"submit-button": {
@@ -15,13 +16,13 @@
1516
]
1617
},
1718

18-
"password-input": {
19+
"signup-password-input": {
1920
"selectorData": "[data-testid='new-password-input-field']",
2021
"strategy": "css",
2122
"groups": []
2223
},
2324

24-
"password-repeat-input": {
25+
"signup-password-repeat-input": {
2526
"selectorData": "[data-testid='verify-password-input-field']",
2627
"strategy": "css",
2728
"groups": []
@@ -39,12 +40,24 @@
3940
"groups": []
4041
},
4142

42-
"otp-input": {
43+
"signup-otp-input": {
4344
"selectorData": "[data-testid='confirm-signup-code-input-field']",
4445
"strategy": "css",
4546
"groups": []
4647
},
4748

49+
"signin-otp-input": {
50+
"selectorData": "[data-testid='signin-token-code-input-field']",
51+
"strategy": "css",
52+
"groups": []
53+
},
54+
55+
"otp-input": {
56+
"selectorData": "input[inputmode='numeric']",
57+
"strategy": "css",
58+
"groups": []
59+
},
60+
4861
"connected-heading": {
4962
"selectorData": "fxa-connected-heading",
5063
"strategy": "id",
@@ -58,7 +71,7 @@
5871
},
5972

6073
"login-password-input": {
61-
"selectorData": "input#password",
74+
"selectorData": "input[type='password']",
6275
"strategy": "css",
6376
"groups": []
6477
},

modules/data/navigation.components.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,18 @@
162162
]
163163
},
164164

165+
"firefox-suggest": {
166+
"selectorData": "div.urlbarView-row[label=\"Firefox Suggest\"] > span.urlbarView-row-inner",
167+
"strategy": "css",
168+
"groups": []
169+
},
170+
171+
"search-result-autofill-adaptive-element": {
172+
"selectorData": ".//*[@type='autofill_adaptive']",
173+
"strategy": "xpath",
174+
"groups": []
175+
},
176+
165177
"sponsored-site-card": {
166178
"selectorData": "top-site-outer",
167179
"strategy": "class",

modules/page_object.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from modules.page_object_autofill_credit_card import *
1111
from modules.page_object_autofill_test_basic import *
1212
from modules.page_object_example_page import *
13-
from modules.page_object_fxa_new_account import *
13+
from modules.page_object_fxa_home import *
1414
from modules.page_object_generics import *
1515
from modules.page_object_google_search import *
1616
from modules.page_object_wiki_firefox_logo import *

modules/page_object_fxa_new_account.py renamed to modules/page_object_fxa_home.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
from selenium.common.exceptions import NoSuchElementException, TimeoutException
2+
from selenium.webdriver.support import expected_conditions as EC
3+
14
from modules.page_base import BasePage
25

36

4-
class FxaNewAccount(BasePage):
5-
"""
6-
Page Object Model for FxA signup flow.
7-
Initialize with fxa_url=<the url of the FxA instance>
8-
"""
7+
class FxaHome(BasePage):
8+
"""Page Object Model for FxA pages"""
99

1010
URL_TEMPLATE = "{fxa_url}"
1111

@@ -15,16 +15,30 @@ def sign_up_sign_in(self, email: str) -> BasePage:
1515
self.get_element("submit-button").click()
1616
return self
1717

18+
def fill_password(self, password: str) -> BasePage:
19+
self.set_content_context()
20+
self.fill("login-password-input", password, press_enter=False)
21+
self.get_element("submit-button").click()
22+
# If OTP is needed, wait for the field to be ready, else move on.
23+
try:
24+
self.custom_wait(timeout=3).until(
25+
EC.presence_of_element_located(self.get_selector("connected-heading"))
26+
)
27+
except (TimeoutException, NoSuchElementException):
28+
self.element_exists("otp-input")
29+
return self
30+
1831
def create_new_account(self, password: str, age=30) -> BasePage:
1932
"""Fill out the password and age fields, then submit and wait for code"""
20-
self.fill("password-input", password, press_enter=False)
21-
self.fill("password-repeat-input", password, press_enter=False)
33+
self.fill("signup-password-input", password, press_enter=False)
34+
self.fill("signup-password-repeat-input", password, press_enter=False)
2235
self.fill("age-input", str(age), press_enter=False)
36+
self.element_clickable("submit-button")
2337
self.get_element("submit-button").click()
2438
self.element_has_text("card-header", "Enter confirmation code")
2539
return self
2640

27-
def confirm_new_account(self, otp: str) -> BasePage:
41+
def fill_otp_code(self, otp: str) -> BasePage:
2842
"""Given an OTP, confirm the account, submit, and wait for account activation"""
2943
self.fill("otp-input", otp, press_enter=False)
3044
self.get_element("submit-button").click()

modules/page_object_wiki_firefox_logo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def get_image(self) -> WebElement:
2121
return self.get_element("firefox-logo")
2222

2323
def verify_opened_image_url(self):
24+
self.url_contains("wikimedia")
2425
current_url = self.driver.current_url
2526

2627
pattern = r"https://upload\.wikimedia\.org/wikipedia/commons/thumb/a/a0/Firefox_logo%2C_2019\.svg/\d+px-Firefox_logo%2C_2019\.svg\.png"

taskcluster/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ binaryornot==0.4.4 \
1616
--hash=sha256:359501dfc9d40632edc9fac890e19542db1a287bbcfa58175b66658392018061 \
1717
--hash=sha256:b8b71173c917bddcd2c16070412e369c3ed7f0528926f70cac18a6c97fd563e4
1818
# via cookiecutter
19-
certifi==2023.7.22 \
20-
--hash=sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082 \
21-
--hash=sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9
19+
certifi==2024.7.4 \
20+
--hash=sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b \
21+
--hash=sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90
2222
# via requests
2323
chardet==5.2.0 \
2424
--hash=sha256:1b3b6ff479a8c414bc3fa2c0852995695c4a026dcd6d0633b2dd092ca39c1cf7 \
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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://www.nationalgeographic.com/science/")
28+
WebDriverWait(driver, 10).until(
29+
lambda d: tabs.get_tab_title(tabs.get_tab(1)) == "Science"
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("nat")
42+
nav.get_element("firefox-suggest").click()
43+
nav.expect_in_content(
44+
EC.url_contains("https://www.nationalgeographic.com/science/")
45+
)
46+
47+
tabs.set_content_context()
48+
49+
# Open a new tab, type the first 3 characters of the visited URL
50+
tabs.new_tab_by_button()
51+
tabs.wait_for_num_tabs(2)
52+
driver.switch_to.window(driver.window_handles[-1])
53+
nav.type_in_awesome_bar("nat")
54+
55+
autofill_adaptive_element = nav.get_element(
56+
"search-result-autofill-adaptive-element"
57+
)
58+
59+
# Assertion to verify that the 'autofill_adaptive' type is found
60+
assert (
61+
autofill_adaptive_element.get_attribute("type") == "autofill_adaptive"
62+
), f"Expected element type to be 'autofill_adaptive' but found '{autofill_adaptive_element.get_attribute('type')}'"
63+
64+
# Assertion to check the autofilled URL is the expected one
65+
assert (
66+
"nationalgeographic.com/science" in autofill_adaptive_element.text
67+
), "URL 'https://www.nationalgeographic.com/science' not found in autofill suggestions."

0 commit comments

Comments
 (0)