Skip to content

Commit ab39f36

Browse files
committed
Add the requested changes
1 parent f10aab1 commit ab39f36

File tree

2 files changed

+10
-28
lines changed

2 files changed

+10
-28
lines changed

modules/page_object_autofill.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -511,24 +511,6 @@ def verify_autofill_data_on_hover(
511511
[value in val for val in autofill_data.__dict__.values()]
512512
)
513513

514-
# Special handling for Austrian phone numbers with duplicated country code
515-
if not is_present and field == "tel" and region == "AT":
516-
# Check if this is the Austrian phone duplication issue
517-
# Browser provides duplicated country code (e.g., '43439839147007'), test data has correct format (e.g., '439839147007')
518-
if value.startswith("4343") and len(value) > 12:
519-
# Try to find a match by removing the duplicated '43'
520-
corrected_value = "43" + value[4:]
521-
is_present = any(
522-
[
523-
corrected_value in val
524-
for val in autofill_data.__dict__.values()
525-
]
526-
)
527-
if is_present:
528-
logging.info(
529-
f"Fixed Austrian phone duplication: {value} -> {corrected_value}"
530-
)
531-
532514
assert is_present, (
533515
f"Mismatched data: {(field, value)} not in {autofill_data.__dict__.values()}."
534516
)

modules/util.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,16 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
571571
"AT": "43",
572572
}
573573

574+
# Handle leading zero in local numbers
575+
if region not in ["US", "CA"] and phone.startswith("0"):
576+
# Remove the leading zero
577+
phone = phone[1:]
578+
579+
# Fix Austrian phone number duplication issue before processing
580+
if region == "AT" and "4343" in phone:
581+
# Remove the duplicated country code
582+
phone = phone.replace("4343", "43")
583+
574584
# If phone is already normalized, return as it is
575585
expected_country_code = country_codes.get(region)
576586
if (
@@ -581,11 +591,6 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
581591
):
582592
return phone
583593

584-
# Fix Austrian phone number duplication issue before processing
585-
if region == "AT" and "4343" in phone:
586-
# Remove the duplicated country code
587-
phone = phone.replace("4343", "43")
588-
589594
# Sub out anything that matches this regex statement with an empty string to get rid of extensions in generated phone numbers
590595
phone = re.sub(r"\s*(?:x|ext)\s*\d*$", "", phone, flags=re.IGNORECASE)
591596
# Sub out anything that is not a digit with the empty string to ensure the phone number is formatted with no spaces or special characters
@@ -603,11 +608,6 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
603608
# Remove country code from the local number
604609
local_number = digits[len(country_code) :]
605610

606-
# Handle leading zero in local numbers
607-
if region not in ["US", "CA"] and local_number.startswith("0"):
608-
# Remove the leading zero
609-
local_number = local_number[1:]
610-
611611
# Validate local number length
612612
if len(local_number) < 6: # Too short to be valid
613613
logging.warning(f"Invalid phone number format: {phone}")

0 commit comments

Comments
 (0)