Skip to content

Commit 4dcb9ef

Browse files
committed
Merge branch 'main' into vs/test_default_search_provide_can_be_changed
2 parents 1a84c92 + 919035d commit 4dcb9ef

16 files changed

+407
-46
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_panel_ui.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ def click_sync_sign_in_button(self) -> BasePage:
8282
self.select_panel_setting("fxa-sign-in")
8383
return self
8484

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+
8594
def manage_fxa_account(self) -> BasePage:
8695
"""
8796
Open the FxA management flow.
@@ -97,5 +106,19 @@ def confirm_sync_in_progress(self) -> BasePage:
97106
"""
98107
with self.driver.context(self.driver.CONTEXT_CHROME):
99108
self.click_sync_sign_in_button()
100-
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()
101124
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: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,29 @@
160160
"groups": [
161161
"doNotCache"
162162
]
163+
},
164+
165+
"sponsored-site-card": {
166+
"selectorData": "top-site-outer",
167+
"strategy": "class",
168+
"groups": []
169+
},
170+
171+
"sponsored-site-card-menu-button": {
172+
"selectorData": "button[class=\"context-menu-button icon\"]",
173+
"strategy": "css",
174+
"groups": []
175+
},
176+
177+
"sponsored-site-context-menu": {
178+
"selectorData": "context-menu",
179+
"strategy": "class",
180+
"groups": []
181+
},
182+
183+
"sponsored-site-context-menu-list": {
184+
"selectorData": "ul[class=\"context-menu-list\"]",
185+
"strategy": "css",
186+
"groups": []
163187
}
164-
}
188+
}

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"

modules/util.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import re
77
from os import remove
88
from random import shuffle
9-
from typing import Literal, Union
9+
from typing import List, Literal, Union
1010

1111
from faker import Faker
1212
from faker.providers import internet, misc
@@ -266,6 +266,56 @@ def fake_credit_card_data(self) -> CreditCardBase:
266266

267267
return fake_data
268268

269+
def write_css_properties(
270+
self, file_path: str, element: WebElement, driver: Firefox, chrome=False
271+
):
272+
"""
273+
Executes JavaScript to get all of the CSS properties of a WebElement then dumps it in the specified file path location. Outputs in JSON format
274+
"""
275+
css_properties = ""
276+
if chrome:
277+
with driver.context(driver.CONTEXT_CHROME):
278+
css_properties = driver.execute_script(
279+
"""
280+
var s = window.getComputedStyle(arguments[0]);
281+
var props = {};
282+
for (var i = 0; i < s.length; i++) {
283+
props[s[i]] = s.getPropertyValue(s[i]);
284+
}
285+
return props;
286+
""",
287+
element,
288+
)
289+
290+
else:
291+
css_properties = driver.execute_script(
292+
"""
293+
var s = window.getComputedStyle(arguments[0]);
294+
var props = {};
295+
for (var i = 0; i < s.length; i++) {
296+
props[s[i]] = s.getPropertyValue(s[i]);
297+
}
298+
return props;
299+
""",
300+
element,
301+
)
302+
303+
with open(file_path, "w") as file:
304+
json.dump(css_properties, file, indent=4)
305+
logging.info(f"CSS properties saved to {file_path}")
306+
307+
def match_regex(self, pattern: str, to_match: List[str]) -> List[str]:
308+
"""
309+
Given a list of logs/strings, this method will return the matches within the string that match the given regex expression.
310+
"""
311+
matches = []
312+
for string in to_match:
313+
match = re.findall(pattern, string)
314+
if len(match) > 0:
315+
matches.append(match[0])
316+
317+
return matches
318+
269319
def normalize_phone_number(self, phone: str, default_country_code="1") -> str:
270320
"""
271321
Given a phone number in some format, +1(xxx)-xxx-xxxx or something similar, it will strip the phone number

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 \

tests/address_bar_and_search/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ def set_prefs(add_prefs: dict):
2020
("privacy.donottrackheader.enabled", False),
2121
("telemetry.fog.test.localhost_port", 5312),
2222
("datareporting.healthreport.uploadEnabled", True),
23+
("browser.newtabpage.enabled", True),
24+
("browser.newtabpage.activity-stream.system.showSponsored", True),
25+
("browser.newtabpage.activity-stream.showSponsoredTopSites", True),
26+
("browser.topsites.useRemoteSetting", True),
27+
("browser.topsites.contile.enabled", True),
2328
]
2429
prefs.extend(add_prefs)
2530
return prefs

0 commit comments

Comments
 (0)