Skip to content

Commit 2f5a59e

Browse files
minor changes to l10n tests and added new test to verify saved addresses
1 parent b967f89 commit 2f5a59e

12 files changed

+282
-111
lines changed

l10n_CM/Unified/conftest.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
import pytest
44

5+
from modules.browser_object_autofill_popup import AutofillPopup
6+
from modules.page_object_autofill import AddressFill, CreditCardFill
7+
from modules.page_object_prefs import AboutPrefs
8+
from modules.util import Utilities
9+
510

611
@pytest.fixture()
712
def region():
@@ -19,8 +24,38 @@ def add_prefs(region: str):
1924

2025

2126
@pytest.fixture()
22-
def set_prefs(add_prefs: dict):
27+
def set_prefs(add_prefs: dict, region: str):
2328
"""Set prefs"""
2429
prefs = []
2530
prefs.extend(add_prefs)
2631
return prefs
32+
33+
34+
@pytest.fixture()
35+
def address_autofill(driver):
36+
yield AddressFill(driver)
37+
38+
39+
@pytest.fixture()
40+
def address_autofill_popup(driver):
41+
yield AutofillPopup(driver)
42+
43+
44+
@pytest.fixture()
45+
def util():
46+
yield Utilities()
47+
48+
49+
@pytest.fixture()
50+
def about_prefs(driver):
51+
yield AboutPrefs(driver, category="privacy")
52+
53+
54+
@pytest.fixture()
55+
def about_prefs_cc_popup(driver):
56+
yield AboutPrefs(driver)
57+
58+
59+
@pytest.fixture()
60+
def credit_card_fill_obj(driver):
61+
yield CreditCardFill(driver)

l10n_CM/Unified/test_demo_ad_address_data_captured_in_doorhanger_and_stored.py

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44
from modules.browser_object_autofill_popup import AutofillPopup
55
from modules.page_object_autofill import AddressFill
66
from modules.page_object_prefs import AboutPrefs
7-
from modules.util import Utilities, BrowserActions
8-
7+
from modules.util import Utilities
98

109

1110
@pytest.fixture()
1211
def test_case():
1312
return "2888703"
1413

1514

16-
def test_demo_ad_address_data_captured_in_doorhanger_and_stored(driver: Firefox, region: str):
15+
def test_demo_ad_address_data_captured_in_doorhanger_and_stored(
16+
driver: Firefox,
17+
region: str,
18+
address_autofill: AddressFill,
19+
util: Utilities,
20+
address_autofill_popup: AutofillPopup,
21+
about_prefs: AboutPrefs,
22+
):
1723
"""
1824
C2888703 - Verify Address data are captured in the Capture Doorhanger and stored in about:preferences
1925
"""
20-
# instantiate objects
21-
address_autofill = AddressFill(driver)
22-
address_autofill_popup = AutofillPopup(driver)
23-
util = Utilities()
24-
browser_action_obj = BrowserActions(driver)
25-
2626
# create fake data and fill it in
2727
address_autofill.open()
2828
address_autofill_data = util.fake_autofill_data(region)
@@ -33,7 +33,9 @@ def test_demo_ad_address_data_captured_in_doorhanger_and_stored(driver: Firefox,
3333

3434
# containing Street Address field
3535
expected_street_add = address_autofill_data.street_address
36-
address_autofill_popup.element_has_text("address-doorhanger-street", expected_street_add)
36+
address_autofill_popup.element_has_text(
37+
"address-doorhanger-street", expected_street_add
38+
)
3739

3840
# containing City field
3941
expected_city = address_autofill_data.address_level_2
@@ -42,36 +44,47 @@ def test_demo_ad_address_data_captured_in_doorhanger_and_stored(driver: Firefox,
4244
expected_state = address_autofill_data.address_level_1
4345
if region not in ["FR", "DE"]:
4446
state_abbreviation = util.get_state_province_abbreviation(expected_state)
45-
address_autofill_popup.element_has_text("address-doorhanger-state", state_abbreviation)
47+
address_autofill_popup.element_has_text(
48+
"address-doorhanger-state", state_abbreviation
49+
)
4650

4751
# Verify Zip Code field (Different selector for DE/FR)
4852
expected_zip = address_autofill_data.postal_code
49-
zip_selector = "address-doorhanger-zip-other" if region in ["FR", "DE"] else "address-doorhanger-zip"
53+
zip_selector = (
54+
"address-doorhanger-zip-other"
55+
if region in ["FR", "DE"]
56+
else "address-doorhanger-zip"
57+
)
5058
address_autofill_popup.element_has_text(zip_selector, expected_zip)
5159

5260
# containing Country field
5361
expected_country = address_autofill_data.country
54-
address_autofill_popup.element_has_text("address-doorhanger-country", expected_country)
62+
address_autofill_popup.element_has_text(
63+
"address-doorhanger-country", expected_country
64+
)
5565

5666
# Click the "Save" button
5767
address_autofill_popup.click_doorhanger_button("save")
5868

5969
# Navigate to about:preferences#privacy => "Autofill" section
60-
about_prefs = AboutPrefs(driver, category="privacy").open()
61-
iframe = about_prefs.get_save_addresses_popup_iframe()
62-
browser_action_obj.switch_to_iframe_context(iframe)
70+
about_prefs.open()
71+
about_prefs.switch_to_saved_addresses_popup_iframe()
6372

6473
# Verify saved addresses
6574
elements = about_prefs.get_elements("saved-addresses-values")
6675

6776
# Expected values for verification
68-
expected_values = [expected_street_add, expected_city, expected_zip, expected_country]
77+
expected_values = [
78+
expected_street_add,
79+
expected_city,
80+
expected_zip,
81+
expected_country,
82+
]
6983
if region not in ["FR", "DE"]:
7084
expected_values.insert(2, expected_state)
7185

7286
# Check if all expected values exist in any saved address
7387
found_address_data = any(
74-
all(value in element.text for value in expected_values)
75-
for element in elements
88+
all(value in element.text for value in expected_values) for element in elements
7689
)
77-
assert found_address_data, "Street, city, state (if applicable), zip, or country were not found in any of the address entries!"
90+
assert found_address_data, "Street, city, state (if applicable), zip, or country were not found in any of the address entries!"

l10n_CM/Unified/test_demo_ad_doorhanger_shown_on_valid_address_submission.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from selenium.webdriver import Firefox
33

44
from modules.browser_object_autofill_popup import AutofillPopup
5-
from modules.page_object import AboutConfig
65
from modules.page_object_autofill import AddressFill
76
from modules.util import Utilities
87

@@ -13,21 +12,15 @@ def test_case():
1312

1413

1514
def test_address_doorhanger_displayed_after_entering_valid_address(
16-
driver: Firefox, region: str
15+
driver: Firefox,
16+
region: str,
17+
address_autofill: AddressFill,
18+
util: Utilities,
19+
address_autofill_popup: AutofillPopup,
1720
):
1821
"""
1922
C2886581 - Verify the Capture Doorhanger is displayed after entering valid Address data
2023
"""
21-
22-
# Instantiate objects
23-
address_autofill = AddressFill(driver)
24-
address_autofill_popup = AutofillPopup(driver)
25-
util = Utilities()
26-
about_config = AboutConfig(driver)
27-
28-
# Change pref value of region
29-
about_config.change_config_value("browser.search.region", region)
30-
3124
# Create fake data and fill it in
3225
address_autofill.open()
3326
address_autofill_data = util.fake_autofill_data(region)

l10n_CM/Unified/test_demo_ad_name_org_captured_in_doorhanger_and_stored.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
from selenium.webdriver import Firefox
33

44
from modules.browser_object_autofill_popup import AutofillPopup
5-
from modules.page_object_about_pages import AboutConfig
65
from modules.page_object_autofill import AddressFill
76
from modules.page_object_prefs import AboutPrefs
8-
from modules.util import BrowserActions, Utilities
7+
from modules.util import Utilities
98

109

1110
@pytest.fixture()
@@ -14,21 +13,15 @@ def test_case():
1413

1514

1615
def test_demo_ad_name_org_captured_in_doorhanger_and_stored(
17-
driver: Firefox, region: str
16+
driver: Firefox,
17+
region: str,
18+
address_autofill: AddressFill,
19+
util: Utilities,
20+
address_autofill_popup: AutofillPopup,
1821
):
1922
"""
2023
C2888701 - Verify name/org fields are captured in the Capture Doorhanger and stored in about:preferences
2124
"""
22-
# instantiate objects
23-
address_autofill = AddressFill(driver)
24-
address_autofill_popup = AutofillPopup(driver)
25-
util = Utilities()
26-
about_config = AboutConfig(driver)
27-
browser_action_obj = BrowserActions(driver)
28-
29-
# Change pref value of region
30-
about_config.change_config_value("browser.search.region", region)
31-
3225
# create fake data and fill it in
3326
address_autofill.open()
3427
address_autofill_data = util.fake_autofill_data(region)
@@ -50,8 +43,7 @@ def test_demo_ad_name_org_captured_in_doorhanger_and_stored(
5043

5144
# Navigate to about:preferences#privacy => "Autofill" section
5245
about_prefs = AboutPrefs(driver, category="privacy").open()
53-
iframe = about_prefs.get_save_addresses_popup_iframe()
54-
browser_action_obj.switch_to_iframe_context(iframe)
46+
about_prefs.switch_to_saved_addresses_popup_iframe()
5547

5648
# The address saved in step 2 is listed in the "Saved addresses" modal: name and organization
5749
elements = about_prefs.get_elements("saved-addresses-values")

l10n_CM/Unified/test_demo_cc_add_new_credit_card.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,29 @@
33
import pytest
44
from selenium.webdriver import Firefox
55

6-
from modules.page_object import AboutConfig, AboutPrefs
7-
from modules.util import BrowserActions, Utilities
6+
from modules.page_object import AboutPrefs
7+
from modules.util import Utilities
88

99

1010
@pytest.fixture()
1111
def test_case():
1212
return "2886595"
1313

1414

15-
def test_create_new_cc_profile(driver: Firefox, region: str):
15+
def test_create_new_cc_profile(
16+
driver: Firefox,
17+
region: str,
18+
util: Utilities,
19+
about_prefs: AboutPrefs,
20+
about_prefs_cc_popup: AboutPrefs,
21+
):
1622
"""
1723
C2886595 - Tests you can create and save a new Credit Card profile
1824
"""
1925

20-
# Instantiate objects
21-
util = Utilities()
22-
browser_action_obj = BrowserActions(driver)
23-
about_prefs = AboutPrefs(driver, category="privacy")
24-
about_prefs_cc_popup = AboutPrefs(driver)
25-
about_config = AboutConfig(driver)
26-
27-
# Change pref value of region
28-
about_config.change_config_value("browser.search.region", region)
29-
3026
# Go to about:preferences#privacy and open Saved Payment Methods
3127
about_prefs.open()
32-
iframe = about_prefs.get_saved_payments_popup_iframe()
33-
browser_action_obj.switch_to_iframe_context(iframe)
28+
about_prefs.switch_to_saved_payments_popup_iframe()
3429

3530
# Save CC information using fake data
3631
credit_card_sample_data = util.fake_credit_card_data()

l10n_CM/Unified/test_demo_cc_doorhanger_shown_on_valid_credit_card_submission.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from selenium.webdriver import Firefox
33

44
from modules.browser_object_autofill_popup import AutofillPopup
5-
from modules.page_object import AboutConfig
65
from modules.page_object_autofill import CreditCardFill
76
from modules.util import Utilities
87

@@ -12,20 +11,16 @@ def test_case():
1211
return "2889441"
1312

1413

15-
def test_cc_check_door_hanger_is_displayed(driver: Firefox, region: str):
14+
def test_cc_check_door_hanger_is_displayed(
15+
driver: Firefox,
16+
region: str,
17+
util: Utilities,
18+
address_autofill_popup: AutofillPopup,
19+
credit_card_fill_obj: CreditCardFill,
20+
):
1621
"""
1722
C2889441 - Ensures that the door hanger is displayed after filling credit card info
1823
"""
19-
20-
# Instantiate objects
21-
autofill_popup_obj = AutofillPopup(driver)
22-
credit_card_fill_obj = CreditCardFill(driver)
23-
util = Utilities()
24-
about_config = AboutConfig(driver)
25-
26-
# Change pref value of region
27-
about_config.change_config_value("browser.search.region", region)
28-
2924
# Navigate to page
3025
credit_card_fill_obj.open()
3126

@@ -34,4 +29,4 @@ def test_cc_check_door_hanger_is_displayed(driver: Firefox, region: str):
3429
credit_card_fill_obj.fill_credit_card_info(credit_card_sample_data)
3530

3631
# Check if an element from the door hanger is visible
37-
autofill_popup_obj.element_visible("doorhanger-save-button")
32+
address_autofill_popup.element_visible("doorhanger-save-button")

l10n_CM/Unified/test_demo_cc_dropdown-presence.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,30 @@
33

44
from modules.browser_object_autofill_popup import AutofillPopup
55
from modules.page_object import AboutPrefs, CreditCardFill
6-
from modules.util import BrowserActions, Utilities
6+
from modules.util import Utilities
77

88

99
@pytest.fixture()
1010
def test_case():
1111
return "2886598"
1212

1313

14-
def test_dropdown_presence_credit_card(driver: Firefox):
14+
def test_dropdown_presence_credit_card(
15+
driver: Firefox,
16+
util: Utilities,
17+
address_autofill_popup: AutofillPopup,
18+
about_prefs: AboutPrefs,
19+
about_prefs_cc_popup: AboutPrefs,
20+
credit_card_fill_obj: CreditCardFill,
21+
):
1522
"""
1623
C2886598 - Verify autofill dropdown is displayed only for the eligible fields after a credit card is saved
1724
"""
1825

19-
# Initialize objects
20-
util = Utilities()
21-
about_prefs = AboutPrefs(driver, category="privacy")
22-
about_prefs_cc_popup = AboutPrefs(driver)
23-
browser_action_obj = BrowserActions(driver)
24-
credit_card_fill_obj = CreditCardFill(driver)
25-
autofill_popup_obj = AutofillPopup(driver)
26-
2726
# Save a credit card in about:preferences
2827
about_prefs.open()
29-
iframe = about_prefs.get_saved_payments_popup_iframe()
30-
browser_action_obj.switch_to_iframe_context(iframe)
28+
about_prefs.switch_to_saved_payments_popup_iframe()
29+
3130
credit_card_sample_data = util.fake_credit_card_data()
3231
about_prefs_cc_popup.click_on(
3332
"panel-popup-button", labels=["autofill-manage-add-button"]
@@ -38,4 +37,4 @@ def test_dropdown_presence_credit_card(driver: Firefox):
3837
credit_card_fill_obj.open()
3938

4039
# Verify autofill dropdown is displayed only for the eligible fields
41-
credit_card_fill_obj.verify_autofill_dropdown_all_fields(autofill_popup_obj)
40+
credit_card_fill_obj.verify_autofill_dropdown_all_fields(address_autofill_popup)

0 commit comments

Comments
 (0)