Skip to content

Commit 18348b9

Browse files
Merge branch 'main' into philimon/suite_refactor
2 parents 3ab7306 + 5d68992 commit 18348b9

14 files changed

+172
-118
lines changed

SELECTOR_INFO.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,20 @@ Location: about:preferences#search
459459
Path to .json: modules/data/about_prefs.components.json
460460
```
461461
```
462+
Selector Name: form-container
463+
Selector Data: "form"
464+
Description: Form to to fill in saved addresses data
465+
Location: about:preferences#privacy
466+
Path to .json: modules/data/about_prefs.components.json
467+
```
468+
```
469+
Selector Name: save-button
470+
Selector Data: "save"
471+
Description: Button to save filled in address form.
472+
Location: about:preferences#privacy
473+
Path to .json: modules/data/about_prefs.components.json
474+
```
475+
```
462476
Selector Name: find-in-settings
463477
Selector Data: "searchInput"
464478
Description: Find in Settings input field (is a shadow root)

l10n_CM/Unified/test_demo_ad_address_data_captured_in_doorhanger_and_stored.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ def test_demo_ad_address_data_captured_in_doorhanger_and_stored(
5656
autofill_popup.element_has_text(zip_selector, expected_zip)
5757

5858
# Containing Country field
59-
expected_country = address_autofill_data.country
59+
expected_country = address_autofill_data.country_code
6060

6161
autofill_popup.element_has_text("address-doorhanger-country", expected_country)
6262

6363
# Click the "Save" button
64+
6465
autofill_popup.click_doorhanger_button("save")
6566

6667
# Navigate to about:preferences#privacy => "Autofill" section

l10n_CM/Unified/test_demo_ad_autofill_dropdown_present_for_email_and_phone.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ def test_case():
1212

1313

1414
def test_dropdown_presence_email_phone_field(
15-
driver: Firefox,
16-
region: str,
17-
address_autofill: AddressFill,
18-
util: Utilities,
19-
autofill_popup: AutofillPopup,
15+
driver: Firefox,
16+
region: str,
17+
address_autofill: AddressFill,
18+
util: Utilities,
19+
autofill_popup: AutofillPopup,
2020
):
2121
"""
2222
C2888567 - Verify that the autofill dropdown is displayed for the email and phone fields

l10n_CM/Unified/test_demo_ad_verify_new_address_added.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ def test_case():
1212
return "2886580"
1313

1414

15-
@pytest.fixture()
16-
def region():
17-
return "US"
18-
19-
2015
@pytest.fixture()
2116
def add_to_prefs_list(region: str):
2217
return [
@@ -38,23 +33,25 @@ def test_verify_new_address_is_added(
3833

3934
# open saved addresses and add entry
4035
about_prefs_privacy.open()
36+
about_prefs_privacy.get_saved_addresses_popup().click()
4137
about_prefs_privacy.add_entry_to_saved_addresses(address_autofill_data)
38+
about_prefs_privacy.switch_to_saved_addresses_popup_iframe()
4239

4340
# verify that the address saved is the same.
4441
# The address saved in step 2 is listed in the "Saved addresses" modal: name and organization
4542
elements = about_prefs_privacy.get_element("saved-addresses-values").text.split(",")
4643
address_match = all(
47-
data_sanitizer(element, region, inverted_state_province_abbr)
44+
data_sanitizer(util, element, region, inverted_state_province_abbr)
4845
in address_autofill_data.__dict__.values()
4946
for element in elements
5047
)
5148
assert address_match, "Address found is not equal to address created!"
5249

5350

54-
def data_sanitizer(value: str, region: str, state_province: Dict):
51+
def data_sanitizer(util: Utilities, value: str, region: str, state_province: Dict):
5552
value = value.strip()
5653
if value[0] == "+":
57-
return value[1:]
54+
return util.normalize_phone_number(value)
5855
elif len(value) == 2 and value != region:
5956
return state_province.get(value, value)
6057
return value

l10n_CM/region/US.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
22
"region": "US",
3-
"tests": [
4-
"test_demo_ad_verify_new_address_added.py",
5-
"test_demo_ad_autofill_dropdown_present_for_email_and_phone.py"
6-
]
3+
"tests": []
74
}

l10n_CM/region/Unified.json

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
{
22
"tests": [
3-
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py",
4-
"test_demo_ad_autofill_name_org.py",
5-
"test_demo_ad_autofill_phone_email.py",
6-
"test_demo_ad_doorhanger_shown_on_valid_address_submission.py",
7-
"test_demo_ad_email_phone_captured_in_doorhanger_and_stored.py",
8-
"test_demo_ad_name_org_captured_in_doorhanger_and_stored.py",
9-
"test_demo_ad_verify_new_address_added.py",
10-
"test_demo_cc_add_new_credit_card.py",
11-
"test_demo_cc_clear_form.py",
12-
"test_demo_cc_doorhanger_data_is_stored_in_about_prefs.py",
13-
"test_demo_cc_doorhanger_shown_on_valid_credit_card_submission.py",
14-
"test_demo_cc_dropdown_presence.py",
15-
"test_demo_cc_autofill_from_dropdown.py",
16-
"test_demo_cc_yellow_highlight.py",
17-
"test_demo_ad_autofill_address_fields.py"
18-
"test_demo_ad_yellow_highlight_name_org.py",
19-
"test_demo_ad_yellow_highlight_address.py",
20-
"test_demo_ad_yellow_highlight_phone_email.py",
21-
"test_demo_ad_dropdown_presence_address.py
22-
"test_demo_ad_clear_name_org.py",
23-
"test_demo_ad_clear_address_fields.py",
24-
"test_demo_ad_clear_tel_email.py"
3+
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py",
4+
"test_demo_ad_autofill_name_org.py",
5+
"test_demo_ad_autofill_phone_email.py",
6+
"test_demo_ad_doorhanger_shown_on_valid_address_submission.py",
7+
"test_demo_ad_email_phone_captured_in_doorhanger_and_stored.py",
8+
"test_demo_ad_name_org_captured_in_doorhanger_and_stored.py",
9+
"test_demo_ad_verify_new_address_added.py",
10+
"test_demo_cc_add_new_credit_card.py",
11+
"test_demo_cc_clear_form.py",
12+
"test_demo_cc_doorhanger_data_is_stored_in_about_prefs.py",
13+
"test_demo_cc_doorhanger_shown_on_valid_credit_card_submission.py",
14+
"test_demo_cc_dropdown_presence.py",
15+
"test_demo_cc_autofill_from_dropdown.py",
16+
"test_demo_cc_yellow_highlight.py",
17+
"test_demo_ad_autofill_address_fields.py",
18+
"test_demo_ad_yellow_highlight_name_org.py",
19+
"test_demo_ad_yellow_highlight_address.py",
20+
"test_demo_ad_yellow_highlight_phone_email.py",
21+
"test_demo_ad_dropdown_presence_address.py",
22+
"test_demo_ad_clear_name_org.py",
23+
"test_demo_ad_clear_address_fields.py",
24+
"test_demo_ad_clear_tel_email.py",
25+
"test_demo_ad_autofill_dropdown_present_for_email_and_phone.py"
2526
]
2627
}

modules/classes/autofill_base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class AutofillAddressBase:
1010
address_level_1: str | None = None
1111
postal_code: str | None = None
1212
country: str | None = None
13+
country_code: str | None = None
1314
email: str | None = None
1415
telephone: str | None = None
1516
"""
@@ -31,6 +32,8 @@ class AutofillAddressBase:
3132
The postal code for the address.
3233
country : str | None
3334
The country of the address.
35+
country_code: str | None
36+
The code of the country.
3437
email : str | None
3538
The email address associated with the address.
3639
telephone : str | None

modules/data/about_prefs.components.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,18 @@
504504
"groups": []
505505
},
506506

507+
"form-container": {
508+
"selectorData": "form",
509+
"strategy": "id",
510+
"groups": []
511+
},
512+
513+
"save-button": {
514+
"selectorData": "save",
515+
"strategy": "id",
516+
"groups": []
517+
},
518+
507519
"reenter-new-password": {
508520
"selectorData": "pw2",
509521
"strategy": "id",

modules/page_base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,11 @@ def wait_for_num_tabs(self, num_tabs: int) -> Page:
703703
)
704704
return self
705705

706+
def switch_to_default_frame(self) -> Page:
707+
"""Switch to default content frame"""
708+
self.driver.switch_to.default_content()
709+
return self
710+
706711
def switch_to_new_tab(self) -> Page:
707712
"""Get list of all window handles, switch to the newly opened tab"""
708713
with self.driver.context(self.driver.CONTEXT_CONTENT):

modules/page_object_autofill.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ def save_information_basic(self, autofill_info: AutofillAddressBase):
482482
"address-level2": autofill_info.address_level_2,
483483
"address-level1": autofill_info.address_level_1,
484484
"postal-code": autofill_info.postal_code,
485-
"country": autofill_info.country,
485+
"country": autofill_info.country_code,
486486
"email": autofill_info.email,
487487
"tel": autofill_info.telephone,
488488
}
@@ -547,7 +547,7 @@ def verify_autofill_data(
547547
"City": autofill_data.address_level_2,
548548
"State": autofill_data.address_level_1,
549549
"ZIP Code": autofill_data.postal_code,
550-
"Country": autofill_data.country,
550+
"Country": autofill_data.country_code,
551551
"Email": autofill_data.email,
552552
"Phone": util.normalize_regional_phone_numbers(
553553
autofill_data.telephone, region
@@ -597,7 +597,11 @@ def verify_autofill_dropdown_addresses(
597597
)
598598

599599
def autofill_and_verify(
600-
self, address_autofill_popup, field_label, address_autofill_data, util
600+
self,
601+
address_autofill_popup,
602+
field_label,
603+
address_autofill_data: AutofillAddressBase,
604+
util,
601605
):
602606
"""
603607
Autofills a form field, verifies the data, and clears it if necessary.
@@ -609,13 +613,13 @@ def autofill_and_verify(
609613
The popup handler for autofill suggestions.
610614
field_label : str
611615
The label of the field being autofilled.
612-
address_autofill_data : dict
616+
address_autofill_data : AutofillAddressBase
613617
The generated autofill data for verification.
614618
region : str
615619
The region code to handle localization.
616620
"""
617621
# Skip address-level1 (State) selection for DE and FR
618-
if field_label == "address-level1" and address_autofill_data.country in [
622+
if field_label == "address-level1" and address_autofill_data.country_code in [
619623
"DE",
620624
"FR",
621625
]:
@@ -628,7 +632,7 @@ def autofill_and_verify(
628632

629633
# Verify autofill data
630634
self.verify_autofill_data(
631-
address_autofill_data, address_autofill_data.country, util
635+
address_autofill_data, address_autofill_data.country_code, util
632636
)
633637

634638
# Clear form autofill
@@ -662,7 +666,10 @@ def verify_all_fields_cleared(self):
662666
assert not value, f"Field '{field}' is not empty: Found '{value}'"
663667

664668
def clear_and_verify(
665-
self, address_autofill_popup, field_label, address_autofill_data
669+
self,
670+
address_autofill_popup,
671+
field_label,
672+
address_autofill_data: AutofillAddressBase,
666673
):
667674
"""
668675
Autofills a form field, clears it, and verifies that it is empty.
@@ -680,7 +687,7 @@ def clear_and_verify(
680687
The region code to handle localization.
681688
"""
682689
# Skip address-level1 (State) selection for DE and FR
683-
if field_label == "address-level1" and address_autofill_data.country in [
690+
if field_label == "address-level1" and address_autofill_data.country_code in [
684691
"DE",
685692
"FR",
686693
]:

0 commit comments

Comments
 (0)