Skip to content

Commit cd2bf36

Browse files
Hani YacoubHani Yacoub
authored andcommitted
Test add doorhanger captures address data
1 parent 13ead4f commit cd2bf36

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
4+
from modules.browser_object_autofill_popup import AutofillPopup
5+
from modules.page_object_about_pages import AboutConfig
6+
from modules.page_object_autofill import AddressFill
7+
from modules.page_object_prefs import AboutPrefs
8+
from modules.util import Utilities, BrowserActions
9+
10+
11+
12+
@pytest.fixture()
13+
def test_case():
14+
return "2888701"
15+
16+
17+
def test_demo_ad_address_data_captured_in_doorhanger_and_stored(driver: Firefox, region: str):
18+
"""
19+
C2888703 - Verify Address data are captured in the Capture Doorhanger and stored in about:preferences
20+
"""
21+
# instantiate objects
22+
address_autofill = AddressFill(driver)
23+
address_autofill_popup = AutofillPopup(driver)
24+
util = Utilities()
25+
about_config = AboutConfig(driver)
26+
browser_action_obj = BrowserActions(driver)
27+
28+
# Change pref value of region
29+
about_config.change_config_value("browser.search.region", region)
30+
31+
# create fake data and fill it in
32+
address_autofill.open()
33+
address_autofill_data = util.fake_autofill_data(region)
34+
address_autofill.save_information_basic(address_autofill_data)
35+
36+
# The "Save address?" doorhanger is displayed
37+
address_autofill_popup.element_visible("address-save-doorhanger")
38+
39+
# containing Street Address field
40+
expected_street_add = address_autofill_data.street_address
41+
address_autofill_popup.element_has_text("address-doorhanger-street", expected_street_add)
42+
43+
# containing City field
44+
expected_city = address_autofill_data.address_level_2
45+
address_autofill_popup.element_has_text("address-doorhanger-city", expected_city)
46+
47+
# containing State/Province field
48+
expected_state = address_autofill_data.address_level_1
49+
address_autofill_popup.element_has_text("address-doorhanger-state", expected_state)
50+
51+
# containing Zip code field
52+
expected_zip = address_autofill_data.postal_code
53+
address_autofill_popup.element_has_text("address-doorhanger-zip", expected_zip)
54+
55+
# containing Country field
56+
expected_country = address_autofill_data.country
57+
address_autofill_popup.element_has_text("address-doorhanger-country", expected_country)
58+
59+
# Click the "Save" button
60+
address_autofill_popup.click_doorhanger_button("save")
61+
62+
# Navigate to about:preferences#privacy => "Autofill" section
63+
about_prefs = AboutPrefs(driver, category="privacy").open()
64+
iframe = about_prefs.get_save_addresses_popup_iframe()
65+
browser_action_obj.switch_to_iframe_context(iframe)
66+
67+
# The address saved in step 2 is listed in the "Saved addresses" modal: Street, city, state, zip and country
68+
elements = about_prefs.get_elements("saved-addresses-values")
69+
expected_values = [expected_street_add, expected_city, expected_zip, expected_country]
70+
found_name_org = any(
71+
all(value in element.text for value in expected_values)
72+
for element in elements
73+
)
74+
assert (
75+
found_name_org
76+
), "Street, city, state, zip or country were not found in any of the address entries!"

modules/data/autofill_popup.components.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,36 @@
8383
"selectorData": "address-save-update-notification-content",
8484
"strategy": "class",
8585
"groups": []
86+
},
87+
88+
"address-doorhanger-street": {
89+
"selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(3) span",
90+
"strategy": "css",
91+
"groups": []
92+
},
93+
94+
"address-doorhanger-city": {
95+
"selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-of-type(1)",
96+
"strategy": "css",
97+
"groups": []
98+
},
99+
100+
"address-doorhanger-state": {
101+
"selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-of-type(3)",
102+
"strategy": "css",
103+
"groups": []
104+
},
105+
106+
"address-doorhanger-zip": {
107+
"selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-of-type(5)",
108+
"strategy": "css",
109+
"groups": []
110+
},
111+
112+
"address-doorhanger-country": {
113+
"selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(5) span",
114+
"strategy": "css",
115+
"groups": []
86116
}
87117
}
88118

0 commit comments

Comments
 (0)