@@ -569,6 +569,64 @@ def verify_field_yellow_highlights(
569
569
expected_highlighted_fields = expected_highlighted_fields ,
570
570
)
571
571
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
+
572
630
573
631
class TextAreaFormAutofill (Autofill ):
574
632
"""
0 commit comments