Skip to content

Commit e60110f

Browse files
authored
Merge branch 'main' into as/dropdown-presence-addresses
2 parents e96fec5 + 95691cd commit e60110f

File tree

5 files changed

+186
-1
lines changed

5 files changed

+186
-1
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
4+
from modules.browser_object_autofill_popup import AutofillPopup
5+
from modules.page_object_autofill import AddressFill
6+
from modules.util import Utilities
7+
8+
9+
@pytest.fixture()
10+
def test_case():
11+
return "2888565"
12+
13+
14+
def test_demo_ad_clear_address_fields(
15+
driver: Firefox,
16+
region: str,
17+
address_autofill: AddressFill,
18+
util: Utilities,
19+
autofill_popup: AutofillPopup
20+
):
21+
"""
22+
C2888565 - Verify clear functionality after selecting an entry from address fields
23+
"""
24+
# Create fake data and fill it in
25+
address_autofill.open()
26+
address_autofill_data = util.fake_autofill_data(region)
27+
address_autofill.save_information_basic(address_autofill_data)
28+
29+
# Click the "Save" button
30+
autofill_popup.click_doorhanger_button("save")
31+
32+
# List of field labels to be autofilled and verified
33+
fields_to_test = [
34+
"street-address",
35+
"address-level2",
36+
"address-level1", # This will be skipped for DE/FR
37+
"postal-code",
38+
"country"
39+
]
40+
41+
# Loop through each field and perform the autofill test
42+
for field in fields_to_test:
43+
address_autofill.clear_and_verify(autofill_popup, field, address_autofill_data)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
4+
from modules.browser_object_autofill_popup import AutofillPopup
5+
from modules.page_object_autofill import AddressFill
6+
from modules.util import Utilities
7+
8+
9+
@pytest.fixture()
10+
def test_case():
11+
return "2888560"
12+
13+
14+
def test_demo_ad_clear_name_org(
15+
driver: Firefox,
16+
region: str,
17+
address_autofill: AddressFill,
18+
util: Utilities,
19+
autofill_popup: AutofillPopup
20+
):
21+
"""
22+
C2888560 - Verify clear functionality after selecting an entry from name/org fields
23+
"""
24+
# Create fake data and fill it in
25+
address_autofill.open()
26+
address_autofill_data = util.fake_autofill_data(region)
27+
address_autofill.save_information_basic(address_autofill_data)
28+
29+
# Click the "Save" button
30+
autofill_popup.click_doorhanger_button("save")
31+
32+
# List of field labels to be autofilled and verified
33+
fields_to_test = [
34+
"name",
35+
"organization"
36+
]
37+
38+
# Loop through each field and perform the autofill test
39+
for field in fields_to_test:
40+
address_autofill.clear_and_verify(autofill_popup, field, address_autofill_data)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
4+
from modules.browser_object_autofill_popup import AutofillPopup
5+
from modules.page_object_autofill import AddressFill
6+
from modules.util import Utilities
7+
8+
9+
@pytest.fixture()
10+
def test_case():
11+
return "2888571"
12+
13+
14+
def test_demo_ad_clear_tel_email(
15+
driver: Firefox,
16+
region: str,
17+
address_autofill: AddressFill,
18+
util: Utilities,
19+
autofill_popup: AutofillPopup
20+
):
21+
"""
22+
C2888571 - Verify clear functionality after selecting an entry from tele/email fields
23+
"""
24+
25+
# Create fake data and fill it in
26+
address_autofill.open()
27+
address_autofill_data = util.fake_autofill_data(region)
28+
address_autofill.save_information_basic(address_autofill_data)
29+
30+
# Click the "Save" button
31+
autofill_popup.click_doorhanger_button("save")
32+
33+
# List of field labels to be autofilled and verified
34+
fields_to_test = [
35+
"email",
36+
"tel"
37+
]
38+
39+
# Loop through each field and perform the autofill test
40+
for field in fields_to_test:
41+
address_autofill.clear_and_verify(autofill_popup, field, address_autofill_data)

l10n_CM/region/Unified.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111
"test_demo_cc_clear_form.py",
1212
"test_demo_cc_doorhanger_data_is_stored_in_about_prefs.py",
1313
"test_demo_cc_doorhanger_shown_on_valid_credit_card_submission.py",
14-
"test_demo_cc_dropdown-presence.py",
14+
"test_demo_cc_dropdown_presence.py",
1515
"test_demo_cc_yellow_highlight.py",
1616
"test_demo_ad_autofill_address_fields.py"
1717
"test_demo_ad_yellow_highlight_name_org.py",
1818
"test_demo_ad_yellow_highlight_address.py",
1919
"test_demo_ad_yellow_highlight_phone_email.py",
2020
"test_demo_ad_dropdown_presence_address.py
21+
"test_demo_ad_clear_name_org.py",
22+
"test_demo_ad_clear_address_fields.py",
23+
"test_demo_ad_clear_tel_email.py"
2124
]
2225
}

modules/page_object_autofill.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,64 @@ def autofill_and_verify(
635635
self.double_click("form-field", labels=[field_label])
636636
address_autofill_popup.click_clear_form_option()
637637

638+
def verify_all_fields_cleared(self):
639+
"""
640+
Verifies that all autofill fields are empty.
641+
"""
642+
field_mapping = {
643+
"Name": "name-field",
644+
"Organization": "org-field",
645+
"Street Address": "street-field",
646+
"City": "add-level2-field",
647+
"State": "add-level1-field",
648+
"ZIP Code": "zip-field",
649+
"Country": "country-field",
650+
"Email": "email-field",
651+
"Phone": "phone-field",
652+
}
653+
654+
# Get actual values from web elements
655+
actual_values = {
656+
field: self.get_element(locator).get_attribute("value")
657+
for field, locator in field_mapping.items()
658+
}
659+
660+
# Validate each field is empty
661+
for field, value in actual_values.items():
662+
assert not value, f"Field '{field}' is not empty: Found '{value}'"
663+
664+
def clear_and_verify(self, address_autofill_popup, field_label, address_autofill_data):
665+
"""
666+
Autofills a form field, clears it, and verifies that it is empty.
667+
Parameters:
668+
----------
669+
address_autofill : AddressFill
670+
The address autofill handler.
671+
address_autofill_popup : AutofillPopup
672+
The popup handler for autofill suggestions.
673+
field_label : str
674+
The label of the field being autofilled.
675+
address_autofill_data : dict
676+
The generated autofill data for verification.
677+
region : str
678+
The region code to handle localization.
679+
"""
680+
# Skip address-level1 (State) selection for DE and FR
681+
if field_label == "address-level1" and address_autofill_data.country in ["DE", "FR"]:
682+
return
683+
684+
# Double-click a field and choose the first element from the autocomplete dropdown
685+
self.double_click("form-field", labels=[field_label])
686+
first_item = address_autofill_popup.get_nth_element(1)
687+
address_autofill_popup.click_on(first_item)
688+
689+
# Clear form autofill
690+
self.double_click("form-field", labels=[field_label])
691+
address_autofill_popup.click_clear_form_option()
692+
693+
# Verify all fields are cleared
694+
self.verify_all_fields_cleared()
695+
638696

639697
class TextAreaFormAutofill(Autofill):
640698
"""

0 commit comments

Comments
 (0)