Skip to content

Commit 6208d33

Browse files
Hani YacoubHani Yacoub
authored andcommitted
Test demo ad autofill name and org
1 parent b967f89 commit 6208d33

File tree

7 files changed

+154
-4
lines changed

7 files changed

+154
-4
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
4+
from modules.browser_object_autofill_popup import AutofillPopup
5+
from modules.page_object_autofill import AddressFill
6+
from modules.util import Utilities
7+
8+
9+
@pytest.fixture()
10+
def test_case():
11+
return "2888703"
12+
13+
14+
def test_demo_ad_autofill_name_org(driver: Firefox, region: str):
15+
"""
16+
C2888558 - Verify Autofill functionality when selecting an entry from the dropdown for name/org fields
17+
"""
18+
# Instantiate objects
19+
address_autofill = AddressFill(driver)
20+
address_autofill_popup = AutofillPopup(driver)
21+
util = Utilities()
22+
23+
# Create fake data and fill it in
24+
address_autofill.open()
25+
address_autofill_data = util.fake_autofill_data(region)
26+
address_autofill.save_information_basic(address_autofill_data)
27+
28+
# Click the "Save" button
29+
address_autofill_popup.click_doorhanger_button("save")
30+
31+
# Double inside Name field and select a saved address entry from the dropdown
32+
address_autofill.double_click("form-field", labels=["name"])
33+
34+
# Click on the first element from the autocomplete dropdown
35+
first_item = address_autofill_popup.get_nth_element(1)
36+
address_autofill_popup.click_on(first_item)
37+
38+
# Verify autofill data
39+
address_autofill.verify_autofill_data(address_autofill_data, region, util)

l10n_CM/region/CA.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"test_demo_ad_doorhanger_shown_on_valid_address_submission.py",
77
"test_demo_ad_name_org_captured_in_doorhanger_and_stored.py",
88
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py",
9-
"test_demo_cc_dropdown-presence.py"
9+
"test_demo_cc_dropdown-presence.py",
10+
"test_demo_ad_autofill_name_org.py"
1011
]
1112
}

l10n_CM/region/DE.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"test_demo_ad_doorhanger_shown_on_valid_address_submission.py",
77
"test_demo_ad_name_org_captured_in_doorhanger_and_stored.py",
88
"test_demo_cc_dropdown-presence.py",
9-
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py"
9+
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py",
10+
"test_demo_ad_autofill_name_org.py"
1011
]
1112
}

l10n_CM/region/FR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"test_demo_ad_doorhanger_shown_on_valid_address_submission.py",
77
"test_demo_ad_name_org_captured_in_doorhanger_and_stored.py",
88
"test_demo_cc_dropdown-presence.py",
9-
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py"
9+
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py",
10+
"test_demo_ad_autofill_name_org.py"
1011
]
1112
}

l10n_CM/region/US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"test_demo_ad_doorhanger_shown_on_valid_address_submission.py",
77
"test_demo_ad_name_org_captured_in_doorhanger_and_stored.py",
88
"test_demo_cc_dropdown-presence.py",
9-
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py"
9+
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py",
10+
"test_demo_ad_autofill_name_org.py"
1011
]
1112
}

modules/data/address_fill.components.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,59 @@
1010
"selectorData": "input[type='{name}']",
1111
"strategy": "css",
1212
"groups": []
13+
},
14+
15+
"name-field": {
16+
"selectorData": "input[autocomplete=name]",
17+
"strategy": "css",
18+
"groups": []
19+
},
20+
21+
"org-field": {
22+
"selectorData": "input[autocomplete=organization]",
23+
"strategy": "css",
24+
"groups": []
25+
},
26+
27+
"street-field": {
28+
"selectorData": "input[autocomplete=street-address]",
29+
"strategy": "css",
30+
"groups": []
31+
},
32+
33+
"add-level2-field": {
34+
"selectorData": "input[autocomplete=address-level2]",
35+
"strategy": "css",
36+
"groups": []
37+
},
38+
39+
"add-level1-field": {
40+
"selectorData": "input[autocomplete=address-level1]",
41+
"strategy": "css",
42+
"groups": []
43+
},
44+
45+
"zip-field": {
46+
"selectorData": "input[autocomplete=postal-code]",
47+
"strategy": "css",
48+
"groups": []
49+
},
50+
51+
"country-field": {
52+
"selectorData": "input[autocomplete=country]",
53+
"strategy": "css",
54+
"groups": []
55+
},
56+
57+
"email-field": {
58+
"selectorData": "input[autocomplete=email]",
59+
"strategy": "css",
60+
"groups": []
61+
},
62+
63+
"phone-field": {
64+
"selectorData": "input[autocomplete=tel]",
65+
"strategy": "css",
66+
"groups": []
1367
}
1468
}

modules/page_object_autofill.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,59 @@ def send_keys_to_element(self, name: str, label: str, keys: str):
397397
elem.clear()
398398
elem.send_keys(new_value)
399399

400+
def verify_autofill_data(self, autofill_data: AutofillAddressBase, region: str, util: Utilities):
401+
"""
402+
Verifies that the autofill data matches the expected values.
403+
404+
:param autofill_data: AutofillAddressBase object containing expected data.
405+
:param region: The region code (e.g., "US", "DE", "FR").
406+
:param util: Utilities instance to normalize values.
407+
"""
408+
field_mapping = {
409+
"Name": "name-field",
410+
"Organization": "org-field",
411+
"Street Address": "street-field",
412+
"City": "add-level2-field",
413+
"State": "add-level1-field",
414+
"ZIP Code": "zip-field",
415+
"Country": "country-field",
416+
"Email": "email-field",
417+
"Phone": "phone-field",
418+
}
419+
420+
# Get actual values from web elements
421+
actual_values = {
422+
field: self.get_element(locator).get_attribute("value")
423+
for field, locator in field_mapping.items()
424+
}
425+
426+
# Get expected values from autofill data
427+
expected_values = {
428+
"Name": autofill_data.name,
429+
"Organization": autofill_data.organization,
430+
"Street Address": autofill_data.street_address,
431+
"City": autofill_data.address_level_2,
432+
"State": autofill_data.address_level_1,
433+
"ZIP Code": autofill_data.postal_code,
434+
"Country": autofill_data.country,
435+
"Email": autofill_data.email,
436+
"Phone": util.normalize_phone_number(autofill_data.telephone),
437+
}
438+
439+
# Validate each field
440+
for field, expected in expected_values.items():
441+
actual = actual_values[field]
442+
443+
# Skip State verification for DE and FR
444+
if field == "State" and region in ["DE", "FR"]:
445+
continue
446+
447+
# Normalize phone numbers before comparison
448+
if field == "Phone":
449+
actual = util.normalize_phone_number(actual)
450+
451+
assert actual == expected, f"Mismatch in {field}: Expected '{expected}', but got '{actual}'"
452+
400453

401454
class TextAreaFormAutofill(Autofill):
402455
"""

0 commit comments

Comments
 (0)