Skip to content

Commit 709fca3

Browse files
Hani YacoubHani Yacoub
authored andcommitted
add methods to pom
1 parent 92d5e3d commit 709fca3

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

l10n_CM/Unified/test_demo_ad_clear_tel_email.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,22 @@ def test_demo_ad_clear_tel_email(
2020
):
2121
"""
2222
C2888571 - Verify clear functionality after selecting an entry from tele/email fields
23-
"""
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"test_demo_cc_doorhanger_shown_on_valid_credit_card_submission.py",
1414
"test_demo_cc_dropdown_presence.py",
1515
"test_demo_ad_verify_new_address_added.py",
16-
"test_demo_ad_yellow_highlight_phone_email.py"
16+
"test_demo_ad_yellow_highlight_phone_email.py",
17+
"test_demo_ad_clear_tel_email.py"
1718
]
1819
}

modules/page_object_autofill.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,64 @@ def verify_field_yellow_highlights(
569569
expected_highlighted_fields=expected_highlighted_fields,
570570
)
571571

572+
def verify_all_fields_cleared(self):
573+
"""
574+
Verifies that all autofill fields are empty.
575+
"""
576+
field_mapping = {
577+
"Name": "name-field",
578+
"Organization": "org-field",
579+
"Street Address": "street-field",
580+
"City": "add-level2-field",
581+
"State": "add-level1-field",
582+
"ZIP Code": "zip-field",
583+
"Country": "country-field",
584+
"Email": "email-field",
585+
"Phone": "phone-field",
586+
}
587+
588+
# Get actual values from web elements
589+
actual_values = {
590+
field: self.get_element(locator).get_attribute("value")
591+
for field, locator in field_mapping.items()
592+
}
593+
594+
# Validate each field is empty
595+
for field, value in actual_values.items():
596+
assert not value, f"Field '{field}' is not empty: Found '{value}'"
597+
598+
def clear_and_verify(self, address_autofill_popup, field_label, address_autofill_data):
599+
"""
600+
Autofills a form field, clears it, and verifies that it is empty.
601+
Parameters:
602+
----------
603+
address_autofill : AddressFill
604+
The address autofill handler.
605+
address_autofill_popup : AutofillPopup
606+
The popup handler for autofill suggestions.
607+
field_label : str
608+
The label of the field being autofilled.
609+
address_autofill_data : dict
610+
The generated autofill data for verification.
611+
region : str
612+
The region code to handle localization.
613+
"""
614+
# Skip address-level1 (State) selection for DE and FR
615+
if field_label == "address-level1" and address_autofill_data.country in ["DE", "FR"]:
616+
return
617+
618+
# Double-click a field and choose the first element from the autocomplete dropdown
619+
self.double_click("form-field", labels=[field_label])
620+
first_item = address_autofill_popup.get_nth_element(1)
621+
address_autofill_popup.click_on(first_item)
622+
623+
# Clear form autofill
624+
self.double_click("form-field", labels=[field_label])
625+
address_autofill_popup.click_clear_form_option()
626+
627+
# Verify all fields are cleared
628+
self.verify_all_fields_cleared()
629+
572630

573631
class TextAreaFormAutofill(Autofill):
574632
"""

0 commit comments

Comments
 (0)