Skip to content

Commit 0d98f74

Browse files
minor change for email phone capture
1 parent 43f9230 commit 0d98f74

29 files changed

+161
-158
lines changed

l10n_CM/Unified/test_demo_ad_address_data_captured_in_doorhanger_and_stored.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,4 @@ def test_demo_ad_address_data_captured_in_doorhanger_and_stored(
8787
found_address_data = any(
8888
all(value in element.text for value in expected_values) for element in elements
8989
)
90-
assert found_address_data, (
91-
"Street, city, state (if applicable), zip, or country were not found in any of the address entries!"
92-
)
90+
assert found_address_data, "Street, city, state (if applicable), zip, or country were not found in any of the address entries!"

l10n_CM/Unified/test_demo_ad_email_phone_captured_in_doorhanger_and_stored.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Dict
2+
13
import pytest
24
from selenium.webdriver import Firefox
35

@@ -13,16 +15,16 @@ def test_case():
1315

1416

1517
def test_demo_ad_email_phone_captured_in_doorhanger_and_stored(
16-
driver: Firefox, region: str
18+
driver: Firefox,
19+
region: str,
20+
address_autofill: AddressFill,
21+
util: Utilities,
22+
address_autofill_popup: AutofillPopup,
23+
about_prefs: AboutPrefs,
1724
):
1825
"""
1926
C2888704 - Verify tele/email data are captured in the Capture Doorhanger and stored in about:preferences
2027
"""
21-
# instantiate objects
22-
address_autofill = AddressFill(driver)
23-
address_autofill_popup = AutofillPopup(driver)
24-
util = Utilities()
25-
browser_action_obj = BrowserActions(driver)
2628

2729
# create fake data and fill it in
2830
address_autofill.open()
@@ -50,16 +52,23 @@ def test_demo_ad_email_phone_captured_in_doorhanger_and_stored(
5052
address_autofill_popup.click_doorhanger_button("save")
5153

5254
# Navigate to about:preferences#privacy => "Autofill" section
53-
about_prefs = AboutPrefs(driver, category="privacy").open()
54-
iframe = about_prefs.get_saved_addresses_popup_iframe()
55-
browser_action_obj.switch_to_iframe_context(iframe)
55+
about_prefs.open()
56+
about_prefs.switch_to_saved_addresses_popup_iframe()
5657

5758
# The address saved in step 2 is listed in the "Saved addresses" modal: Email and phone
58-
elements = about_prefs.get_elements("saved-addresses-values")
59-
expected_values = [expected_phone, expected_email]
60-
found_email_phone = any(
61-
all(value in element.text for value in expected_values) for element in elements
62-
)
63-
assert found_email_phone, (
64-
"Email or phone were not found in any of the address entries!"
59+
elements = map(
60+
data_sanitizer,
61+
about_prefs.get_element("saved-addresses-values").text.split(","),
6562
)
63+
expected_values = [expected_phone, expected_email]
64+
found_email_phone = list(set(elements) & set(expected_values))
65+
assert (
66+
found_email_phone
67+
), "Email or phone were not found in any of the address entries!"
68+
69+
70+
def data_sanitizer(value: str):
71+
value = value.strip()
72+
if value[0] == "+":
73+
return value[1:]
74+
return value

l10n_CM/Unified/test_demo_ad_name_org_captured_in_doorhanger_and_stored.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def test_demo_ad_name_org_captured_in_doorhanger_and_stored(
1818
address_autofill: AddressFill,
1919
util: Utilities,
2020
address_autofill_popup: AutofillPopup,
21+
about_prefs: AboutPrefs,
2122
):
2223
"""
2324
C2888701 - Verify name/org fields are captured in the Capture Doorhanger and stored in about:preferences
@@ -42,7 +43,7 @@ def test_demo_ad_name_org_captured_in_doorhanger_and_stored(
4243
address_autofill_popup.click_doorhanger_button("save")
4344

4445
# Navigate to about:preferences#privacy => "Autofill" section
45-
about_prefs = AboutPrefs(driver, category="privacy").open()
46+
about_prefs.open()
4647
about_prefs.switch_to_saved_addresses_popup_iframe()
4748

4849
# The address saved in step 2 is listed in the "Saved addresses" modal: name and organization
@@ -51,6 +52,6 @@ def test_demo_ad_name_org_captured_in_doorhanger_and_stored(
5152
found_name_org = any(
5253
all(value in element.text for value in expected_values) for element in elements
5354
)
54-
assert found_name_org, (
55-
"Name or organization were not found in any of the address entries!"
56-
)
55+
assert (
56+
found_name_org
57+
), "Name or organization were not found in any of the address entries!"

l10n_CM/Unified/test_demo_cc_clear_form.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,23 @@ def test_case():
1111
return "2886602"
1212

1313

14-
def test_cc_clear_form(driver: Firefox):
14+
def test_cc_clear_form(
15+
driver: Firefox,
16+
util: Utilities,
17+
address_autofill_popup: AutofillPopup,
18+
about_prefs: AboutPrefs,
19+
about_prefs_cc_popup: AboutPrefs,
20+
credit_card_fill_obj: CreditCardFill,
21+
):
1522
"""
1623
C2886602 - Verify that clearing the form from any field results in all fields being emptied, regardless of the
1724
field from which the clear action was triggered.
1825
"""
1926

20-
# Initialize objects
21-
util = Utilities()
22-
about_prefs = AboutPrefs(driver, category="privacy")
23-
about_prefs_cc_popup = AboutPrefs(driver)
24-
browser_action_obj = BrowserActions(driver)
25-
credit_card_fill_obj = CreditCardFill(driver)
26-
autofill_popup = AutofillPopup(driver)
27-
2827
# Save a credit card in about:preferences
2928
about_prefs.open()
30-
iframe = about_prefs.get_saved_payments_popup_iframe()
31-
browser_action_obj.switch_to_iframe_context(iframe)
29+
about_prefs.switch_to_saved_payments_popup_iframe()
30+
3231
credit_card_sample_data = util.fake_credit_card_data()
3332
about_prefs_cc_popup.click_on(
3433
"panel-popup-button", labels=["autofill-manage-add-button"]
@@ -37,4 +36,4 @@ def test_cc_clear_form(driver: Firefox):
3736

3837
# Open credit card form page, clear form and verify all fields are empty
3938
credit_card_fill_obj.open()
40-
credit_card_fill_obj.verify_clear_form_all_fields(autofill_popup)
39+
credit_card_fill_obj.verify_clear_form_all_fields(address_autofill_popup)

modules/browser_object_tracker_panel.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ def verify_tracker_shield_indicator(self, nav: Navigation) -> BasePage:
145145
assert (
146146
shield_icon.get_attribute("data-l10n-id")
147147
== "tracking-protection-icon-active-container"
148-
), (
149-
"The label detected did not correspond to the expected one: tracking-protection-icon-active-container"
150-
)
148+
), "The label detected did not correspond to the expected one: tracking-protection-icon-active-container"
151149
return self
152150

153151
def open_and_return_cross_site_trackers(self) -> List[WebElement]:

modules/page_base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,9 @@ def verify_opened_image_url(self, url_substr: str, pattern: str) -> Page:
437437
self.url_contains(url_substr)
438438
current_url = self.driver.current_url
439439

440-
assert re.match(pattern, current_url), (
441-
f"URL does not match the expected pattern: {current_url}"
442-
)
440+
assert re.match(
441+
pattern, current_url
442+
), f"URL does not match the expected pattern: {current_url}"
443443
return self
444444

445445
def fill(
@@ -490,9 +490,9 @@ def fetch(self, reference: Union[str, tuple, WebElement], labels=[]) -> WebEleme
490490
return self.find_element(*reference)
491491
elif isinstance(reference, WebElement):
492492
return reference
493-
assert False, (
494-
"Bad fetch: only selectors, selector names, or WebElements allowed."
495-
)
493+
assert (
494+
False
495+
), "Bad fetch: only selectors, selector names, or WebElements allowed."
496496

497497
def click_on(self, reference: Union[str, tuple, WebElement], labels=[]) -> Page:
498498
"""Click on an element, no matter the context, return the page"""

tests/address_bar_and_search/test_adaptive_history_autofill.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ def test_add_adaptive_history_autofill(driver: Firefox):
6161
)
6262

6363
# Assertion to verify that the 'autofill_adaptive' type is found
64-
assert autofill_adaptive_element.get_attribute("type") == "autofill_adaptive", (
65-
f"Expected element type to be 'autofill_adaptive' but found '{autofill_adaptive_element.get_attribute('type')}'"
66-
)
64+
assert (
65+
autofill_adaptive_element.get_attribute("type") == "autofill_adaptive"
66+
), f"Expected element type to be 'autofill_adaptive' but found '{autofill_adaptive_element.get_attribute('type')}'"
6767

6868
# Assertion to check the autofilled URL is the expected one
69-
assert "nationalgeographic.com/science" in autofill_adaptive_element.text, (
70-
"URL 'https://www.nationalgeographic.com/science' not found in autofill suggestions."
71-
)
69+
assert (
70+
"nationalgeographic.com/science" in autofill_adaptive_element.text
71+
), "URL 'https://www.nationalgeographic.com/science' not found in autofill suggestions."

tests/address_bar_and_search/test_preferences_all_toggles_enabled.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ def test_preferences_all_toggles_enabled(driver: Firefox):
2929
if not show_suggestions_checkbox.is_selected():
3030
show_suggestions_checkbox.click()
3131
nonsponsored_checkbox = about_prefs.get_element("firefox-suggest-nonsponsored")
32-
assert nonsponsored_checkbox.is_selected(), (
33-
f"Checkbox with selector '{nonsponsored_checkbox}' is not checked"
34-
)
32+
assert (
33+
nonsponsored_checkbox.is_selected()
34+
), f"Checkbox with selector '{nonsponsored_checkbox}' is not checked"
3535
sponsors_checkbox = about_prefs.get_element("firefox-suggest-sponsored")
36-
assert sponsors_checkbox.is_selected(), (
37-
f"Checkbox with selector '{sponsors_checkbox}' is not checked"
38-
)
36+
assert (
37+
sponsors_checkbox.is_selected()
38+
), f"Checkbox with selector '{sponsors_checkbox}' is not checked"
3939

4040
# Check if sponsored suggestion is displayed. Keep checking until the sponsered suggestions are displayed
4141
found = False

tests/address_bar_and_search/test_tile_menu_options.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,6 @@ def test_tile_context_menu_options(driver: Firefox, index: int, sponsored: bool)
138138
set_in_use.remove(match)
139139
logging.info(f"Detected the context item: {match}")
140140

141-
assert len(set_in_use) == 0, (
142-
"Did not find all of the required context menu actions."
143-
)
141+
assert (
142+
len(set_in_use) == 0
143+
), "Did not find all of the required context menu actions."

tests/bookmarks_and_history/test_opened_website_present_in_toolbar_history.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ def test_the_most_recent_website_is_present_in_history_menu(driver: Firefox):
3232
# Verify YouTube is present in the history menu and is on top of the list as the most recent website visited
3333
with driver.context(driver.CONTEXT_CHROME):
3434
recent_history_elements = panel_ui.get_elements("recent-history-content")
35-
assert recent_history_elements[0].get_attribute("value") == "YouTube", (
36-
"YouTube is not the first item in the recent history."
37-
)
35+
assert (
36+
recent_history_elements[0].get_attribute("value") == "YouTube"
37+
), "YouTube is not the first item in the recent history."

0 commit comments

Comments
 (0)