in modules/page_object_autofill.py [0:0]
def fill_and_submit(self, data_object: CreditCardBase | AutofillAddressBase | dict):
"""Fill and submit from data object or dictionary.
Arguments:
data_object: object containing autofill 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."
)
for attr_name, field_name in self.field_mapping.items():
value = (
getattr(data_object, attr_name, None)
if not isinstance(data_object, dict)
else data_object.get(field_name)
)
if value is not None:
self._fill_input_element(field_name, value)
self._click_form_button("submit")