@@ -515,7 +515,7 @@ def verify_autofill_data(
515
515
"ZIP Code" : autofill_data .postal_code ,
516
516
"Country" : autofill_data .country ,
517
517
"Email" : autofill_data .email ,
518
- "Phone" : util .normalize_phone_number (autofill_data .telephone ),
518
+ "Phone" : util .normalize_regional_phone_numbers (autofill_data .telephone , region ),
519
519
}
520
520
521
521
# Validate each field
@@ -528,7 +528,7 @@ def verify_autofill_data(
528
528
529
529
# Normalize phone numbers before comparison
530
530
if field == "Phone" :
531
- actual = util .normalize_phone_number (actual )
531
+ actual = util .normalize_regional_phone_numbers (actual , region )
532
532
533
533
assert actual == expected , (
534
534
f"Mismatch in { field } : Expected '{ expected } ', but got '{ actual } '"
@@ -549,6 +549,38 @@ def verify_field_yellow_highlights(
549
549
expected_highlighted_fields = expected_highlighted_fields ,
550
550
)
551
551
552
+ def autofill_and_verify (self , address_autofill_popup , field_label , address_autofill_data , util ):
553
+ """
554
+ Autofills a form field, verifies the data, and clears it if necessary.
555
+ Parameters:
556
+ ----------
557
+ address_autofill : AddressFill
558
+ The address autofill handler.
559
+ address_autofill_popup : AutofillPopup
560
+ The popup handler for autofill suggestions.
561
+ field_label : str
562
+ The label of the field being autofilled.
563
+ address_autofill_data : dict
564
+ The generated autofill data for verification.
565
+ region : str
566
+ The region code to handle localization.
567
+ """
568
+ # Skip address-level1 (State) selection for DE and FR
569
+ if field_label == "address-level1" and address_autofill_data .country in ["DE" , "FR" ]:
570
+ return
571
+
572
+ # Double-click a field and choose the first element from the autocomplete dropdown
573
+ self .double_click ("form-field" , labels = [field_label ])
574
+ first_item = address_autofill_popup .get_nth_element (1 )
575
+ address_autofill_popup .click_on (first_item )
576
+
577
+ # Verify autofill data
578
+ self .verify_autofill_data (address_autofill_data , address_autofill_data .country , util )
579
+
580
+ # Clear form autofill
581
+ self .double_click ("form-field" , labels = [field_label ])
582
+ address_autofill_popup .click_clear_form_option ()
583
+
552
584
553
585
class TextAreaFormAutofill (Autofill ):
554
586
"""
0 commit comments