def verify_form_data()

in modules/page_object_autofill.py [0:0]


    def verify_form_data(self, sample_data: CreditCardBase | AutofillAddressBase):
        """Verify that form is filled correctly against sample data."""
        if not self.field_mapping:
            # Method is meant to be called by one of the classes that inherit AutoFill (CreditCardFill or AddressFill)
            # Should not be called directly from an Autofill instance.
            raise NotImplementedError(
                "Method should only be called in inherited classes."
            )

        is_address_fill = self.__class__ == AddressFill
        non_us_ca_address = is_address_fill and sample_data.country_code not in [
            "US",
            "CA",
        ]
        for attr_name, field_name in self.field_mapping.items():
            if non_us_ca_address and field_name == "address-level1":
                continue
            if field_name != "cc-csc":
                expected_value = getattr(sample_data, attr_name, None)
                autofilled_field = self.get_element("form-field", labels=[field_name])
                if autofilled_field.tag_name.lower() != "select":
                    autofilled_field_value = autofilled_field.get_attribute("value")
                    # self.expect_element_attribute_contains(
                    #     "form-field", "value", expected_value, labels=[field_name]
                    # )
                else:
                    autofilled_field_value = Select(
                        autofilled_field
                    ).first_selected_option.text
                if (
                    field_name == "address-level1"
                    and autofilled_field_value != expected_value
                ):
                    expected_value = self.util.get_state_province_abbreviation(
                        expected_value
                    )
                assert expected_value in autofilled_field_value, (
                    f"{autofilled_field_value} is different from {expected_value}"
                )