@@ -39,6 +39,43 @@ def click_form_button(self, field_name):
39
39
"""Clicks submit on the form"""
40
40
self .click_on ("submit-button" , labels = [field_name ])
41
41
42
+ def verify_field_autofill_dropdown (
43
+ self ,
44
+ autofill_popup : AutofillPopup ,
45
+ fields_to_test : List [str ],
46
+ excluded_fields : Optional [List [str ]] = None ,
47
+ region : Optional [str ] = None ,
48
+ ):
49
+ """
50
+ A common method to check which fields trigger the autofill dropdown. This is used in both CC and Address pages.
51
+ - fields_to_test: The primary list of fields for this page (cc fields, address fields).
52
+ - excluded_fields: Fields that should NOT trigger an autofill dropdown.
53
+ - region: If provided, handle region-specific behavior (e.g., skip address-level1 for DE/FR).
54
+ """
55
+ # Create a copy of fields_to_test to avoid modifying the original
56
+ fields_to_check = fields_to_test [:]
57
+
58
+ # Handle region-specific behavior
59
+ if region in ["DE" , "FR" ] and "address-level1" in fields_to_check :
60
+ fields_to_check .remove ("address-level1" )
61
+
62
+ # Check fields that SHOULD trigger the autofill dropdown
63
+ for field_name in fields_to_check :
64
+ self .double_click ("form-field" , labels = [field_name ])
65
+ autofill_popup .ensure_autofill_dropdown_visible ()
66
+ logging .info (f"Autofill dropdown appears for field '{ field_name } '." )
67
+
68
+ # Check fields that should NOT trigger the autofill dropdown
69
+ if excluded_fields :
70
+ for field_name in excluded_fields :
71
+ self .double_click ("form-field" , labels = [field_name ])
72
+ autofill_popup .ensure_autofill_dropdown_not_visible ()
73
+ logging .info (
74
+ f"No autofill dropdown appears for field '{ field_name } ', as expected."
75
+ )
76
+
77
+ return self
78
+
42
79
def verify_field_highlight (
43
80
self ,
44
81
fields_to_test : List [str ],
@@ -136,14 +173,11 @@ def fill_credit_card_info(self, info: CreditCardBase):
136
173
137
174
self .click_form_button ("submit" )
138
175
139
- def verify_autofill_dropdown_all_fields (self , ccp : AutofillPopup ):
140
- """Given a CreditCardPopup object, verify all fields"""
141
- for field in self .fields :
142
- self .double_click ("form-field" , labels = [field ])
143
- ccp .ensure_autofill_dropdown_visible ()
144
- # Ensure 'cc-csc' does NOT trigger the autofill dropdown
145
- self .double_click ("form-field" , labels = ["cc-csc" ])
146
- ccp .ensure_autofill_dropdown_not_visible ()
176
+ def verify_autofill_dropdown_credit_card (self , autofill_popup : AutofillPopup ):
177
+ """Verifies autofill dropdown for credit card fields."""
178
+ return self .verify_field_autofill_dropdown (
179
+ autofill_popup , fields_to_test = self .fields , excluded_fields = ["cc-csc" ]
180
+ )
147
181
148
182
def verify_credit_card_form_data (
149
183
self , credit_card_sample_data : CreditCardBase
@@ -551,6 +585,17 @@ def verify_field_yellow_highlights(
551
585
expected_highlighted_fields = expected_highlighted_fields ,
552
586
)
553
587
588
+ def verify_autofill_dropdown_addresses (
589
+ self , autofill_popup : AutofillPopup , region = None , fields_to_test = None
590
+ ):
591
+ """Verifies autofill dropdown for address fields."""
592
+ if fields_to_test is None :
593
+ fields_to_test = self .fields
594
+
595
+ return self .verify_field_autofill_dropdown (
596
+ autofill_popup = autofill_popup , fields_to_test = fields_to_test , region = region
597
+ )
598
+
554
599
def autofill_and_verify (
555
600
self , address_autofill_popup , field_label , address_autofill_data , util
556
601
):
0 commit comments