Skip to content

Commit 6017032

Browse files
authored
Merge pull request #474 from mozilla/Hani/address_autofill_name_org
Hani/Demo ad test for Verify Autofill functionality when selecting an entry from the dropdown for name/org fields
2 parents 184adc4 + 76537ef commit 6017032

File tree

8 files changed

+234
-5
lines changed

8 files changed

+234
-5
lines changed

SELECTOR_INFO.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,69 @@ Description: "Submit" button
11821182
Location: At the bottom of the autofill address demo page - https://mozilla.github.io/form-fill-examples/basic.html
11831183
Path to .json: modules/data/address_fill.components.json
11841184
```
1185+
```
1186+
Selector Name: name-field
1187+
Selector Data: "input[autocomplete=name]"
1188+
Description: Name field
1189+
Location: Name field on autofill address demo page - https://mozilla.github.io/form-fill-examples/basic.html
1190+
Path to .json: modules/data/address_fill.components.json
1191+
```
1192+
```
1193+
Selector Name: org-field
1194+
Selector Data: "input[autocomplete=organization]"
1195+
Description: Organization field
1196+
Location: Organization field on autofill address demo page - https://mozilla.github.io/form-fill-examples/basic.html
1197+
Path to .json: modules/data/address_fill.components.json
1198+
```
1199+
```
1200+
Selector Name: street-field
1201+
Selector Data: "input[autocomplete=street-address]"
1202+
Description: Street field
1203+
Location: Street field on autofill address demo page - https://mozilla.github.io/form-fill-examples/basic.html
1204+
Path to .json: modules/data/address_fill.components.json
1205+
```
1206+
```
1207+
Selector Name: add-level2-field
1208+
Selector Data: "input[autocomplete=address-level2]"
1209+
Description: Address level 2 field
1210+
Location: Address level 2 field on autofill address demo page - https://mozilla.github.io/form-fill-examples/basic.html
1211+
Path to .json: modules/data/address_fill.components.json
1212+
```
1213+
```
1214+
Selector Name: add-level1-field
1215+
Selector Data: "input[autocomplete=address-level1]"
1216+
Description: Address level 1 field
1217+
Location: Address level 1 field on autofill address demo page - https://mozilla.github.io/form-fill-examples/basic.html
1218+
Path to .json: modules/data/address_fill.components.json
1219+
```
1220+
```
1221+
Selector Name: zip-field
1222+
Selector Data: "input[autocomplete=postal-code]"
1223+
Description: Zip field
1224+
Location: Zip field on autofill address demo page - https://mozilla.github.io/form-fill-examples/basic.html
1225+
Path to .json: modules/data/address_fill.components.json
1226+
```
1227+
```
1228+
Selector Name: country-field
1229+
Selector Data: "input[autocomplete=country]"
1230+
Description: Country field
1231+
Location: Country field on autofill address demo page - https://mozilla.github.io/form-fill-examples/basic.html
1232+
Path to .json: modules/data/address_fill.components.json
1233+
```
1234+
```
1235+
Selector Name: email-field
1236+
Selector Data: "input[autocomplete=email]"
1237+
Description: Email field
1238+
Location: Email field on autofill address demo page - https://mozilla.github.io/form-fill-examples/basic.html
1239+
Path to .json: modules/data/address_fill.components.json
1240+
```
1241+
```
1242+
Selector Name: phone-field
1243+
Selector Data: "input[autocomplete=tel]"
1244+
Description: Phone field
1245+
Location: Phone field on autofill address demo page - https://mozilla.github.io/form-fill-examples/basic.html
1246+
Path to .json: modules/data/address_fill.components.json
1247+
```
11851248
#### amo_languages
11861249
```
11871250
Selector Name: language-addons-title
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 "2888558"
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)
40+
41+
# Double inside Name field and select clear form autofill
42+
address_autofill.double_click("form-field", labels=["name"])
43+
address_autofill_popup.click_clear_form_option()
44+
45+
# Double inside Organization field and select a saved address entry from the dropdown
46+
address_autofill.double_click("form-field", labels=["organization"])
47+
48+
# Click on the first element from the autocomplete dropdown
49+
first_item = address_autofill_popup.get_nth_element(1)
50+
address_autofill_popup.click_on(first_item)
51+
52+
# Verify autofill data
53+
address_autofill.verify_autofill_data(address_autofill_data, region, util)

l10n_CM/region/CA.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
"test_demo_cc_doorhanger_shown_on_valid_credit_card_submission.py",
55
"test_demo_cc_add_new_credit_card.py",
66
"test_demo_ad_doorhanger_shown_on_valid_address_submission.py",
7-
"test_demo_ad_email_phone_captured_in_doorhanger_and_stored.py",
87
"test_demo_ad_name_org_captured_in_doorhanger_and_stored.py",
98
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py",
109
"test_demo_cc_dropdown-presence.py",
11-
"test_demo_cc_clear_form.py"
10+
"test_demo_cc_clear_form.py",
11+
"test_demo_cc_dropdown-presence.py",
12+
"test_demo_ad_autofill_name_org.py"
1213
]
1314
}

l10n_CM/region/DE.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
"test_demo_cc_doorhanger_shown_on_valid_credit_card_submission.py",
55
"test_demo_cc_add_new_credit_card.py",
66
"test_demo_ad_doorhanger_shown_on_valid_address_submission.py",
7-
"test_demo_ad_email_phone_captured_in_doorhanger_and_stored.py",
87
"test_demo_ad_name_org_captured_in_doorhanger_and_stored.py",
98
"test_demo_cc_dropdown-presence.py",
109
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py",
10+
"test_demo_ad_autofill_name_org.py",
11+
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py",
1112
"test_demo_cc_clear_form.py"
1213
]
1314
}

l10n_CM/region/FR.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
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",
10+
"test_demo_ad_autofill_name_org.py",
911
"test_demo_ad_email_phone_captured_in_doorhanger_and_stored.py",
10-
"test_demo_cc_dropdown-presence.py"
12+
"test_demo_cc_dropdown-presence.py",
1113
"test_demo_cc_clear_form.py"
1214
]
1315
}

l10n_CM/region/US.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
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",
10+
"test_demo_ad_autofill_name_org.py",
911
"test_demo_ad_email_phone_captured_in_doorhanger_and_stored.py",
10-
"test_demo_cc_dropdown-presence.py"
12+
"test_demo_cc_dropdown-presence.py",
1113
"test_demo_cc_clear_form.py"
1214
]
1315
}

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
@@ -414,6 +414,59 @@ def send_keys_to_element(self, name: str, label: str, keys: str):
414414
elem.clear()
415415
elem.send_keys(new_value)
416416

417+
def verify_autofill_data(self, autofill_data: AutofillAddressBase, region: str, util: Utilities):
418+
"""
419+
Verifies that the autofill data matches the expected values.
420+
421+
:param autofill_data: AutofillAddressBase object containing expected data.
422+
:param region: The region code (e.g., "US", "DE", "FR").
423+
:param util: Utilities instance to normalize values.
424+
"""
425+
field_mapping = {
426+
"Name": "name-field",
427+
"Organization": "org-field",
428+
"Street Address": "street-field",
429+
"City": "add-level2-field",
430+
"State": "add-level1-field",
431+
"ZIP Code": "zip-field",
432+
"Country": "country-field",
433+
"Email": "email-field",
434+
"Phone": "phone-field",
435+
}
436+
437+
# Get actual values from web elements
438+
actual_values = {
439+
field: self.get_element(locator).get_attribute("value")
440+
for field, locator in field_mapping.items()
441+
}
442+
443+
# Get expected values from autofill data
444+
expected_values = {
445+
"Name": autofill_data.name,
446+
"Organization": autofill_data.organization,
447+
"Street Address": autofill_data.street_address,
448+
"City": autofill_data.address_level_2,
449+
"State": autofill_data.address_level_1,
450+
"ZIP Code": autofill_data.postal_code,
451+
"Country": autofill_data.country,
452+
"Email": autofill_data.email,
453+
"Phone": util.normalize_phone_number(autofill_data.telephone),
454+
}
455+
456+
# Validate each field
457+
for field, expected in expected_values.items():
458+
actual = actual_values[field]
459+
460+
# Skip State verification for DE and FR
461+
if field == "State" and region in ["DE", "FR"]:
462+
continue
463+
464+
# Normalize phone numbers before comparison
465+
if field == "Phone":
466+
actual = util.normalize_phone_number(actual)
467+
468+
assert actual == expected, f"Mismatch in {field}: Expected '{expected}', but got '{actual}'"
469+
417470

418471
class TextAreaFormAutofill(Autofill):
419472
"""

0 commit comments

Comments
 (0)