Skip to content

Commit 60ba839

Browse files
Merge pull request #485 from mozilla/philimon/l10n_modify
Philimon/L10N_Script_Modification
2 parents b71e029 + 961ca91 commit 60ba839

17 files changed

+201
-122
lines changed

l10n_CM/Unified/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@pytest.fixture()
1313
def region():
14-
return os.environ.get("STARFOX_REGION", "US")
14+
return os.environ.get("FX_REGION", "US")
1515

1616

1717
@pytest.fixture()
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22
from selenium.webdriver import Firefox
33

4+
from l10n_CM.Unified.conftest import autofill_popup
45
from modules.browser_object_autofill_popup import AutofillPopup
56
from modules.page_object_autofill import AddressFill
67
from modules.util import Utilities
@@ -11,43 +12,44 @@ def test_case():
1112
return "2888558"
1213

1314

14-
def test_demo_ad_autofill_name_org(driver: Firefox, region: str):
15+
def test_demo_ad_autofill_name_org(
16+
driver: Firefox,
17+
region: str,
18+
address_autofill: AddressFill,
19+
autofill_popup: AutofillPopup,
20+
util: Utilities,
21+
):
1522
"""
1623
C2888558 - Verify Autofill functionality when selecting an entry from the dropdown for name/org fields
1724
"""
18-
# Instantiate objects
19-
address_autofill = AddressFill(driver)
20-
address_autofill_popup = AutofillPopup(driver)
21-
util = Utilities()
22-
2325
# Create fake data and fill it in
2426
address_autofill.open()
2527
address_autofill_data = util.fake_autofill_data(region)
2628
address_autofill.save_information_basic(address_autofill_data)
2729

2830
# Click the "Save" button
29-
address_autofill_popup.click_doorhanger_button("save")
31+
autofill_popup.click_doorhanger_button("save")
3032

3133
# Double inside Name field and select a saved address entry from the dropdown
3234
address_autofill.double_click("form-field", labels=["name"])
3335

3436
# 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+
first_item = autofill_popup.get_nth_element(1)
38+
autofill_popup.click_on(first_item)
3739

3840
# Verify autofill data
3941
address_autofill.verify_autofill_data(address_autofill_data, region, util)
4042

4143
# Double inside Name field and select clear form autofill
4244
address_autofill.double_click("form-field", labels=["name"])
43-
address_autofill_popup.click_clear_form_option()
45+
autofill_popup.click_clear_form_option()
4446

4547
# Double inside Organization field and select a saved address entry from the dropdown
4648
address_autofill.double_click("form-field", labels=["organization"])
4749

4850
# 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+
first_item = autofill_popup.get_nth_element(1)
52+
autofill_popup.click_on(first_item)
5153

5254
# Verify autofill data
5355
address_autofill.verify_autofill_data(address_autofill_data, region, util)

l10n_CM/Unified/test_demo_ad_autofill_phone_email.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,45 @@ def test_case():
1111
return "2888569"
1212

1313

14-
def test_demo_ad_autofill_phone_email(driver: Firefox, region: str):
14+
def test_demo_ad_autofill_phone_email(
15+
driver: Firefox,
16+
region: str,
17+
address_autofill: AddressFill,
18+
autofill_popup: AutofillPopup,
19+
util: Utilities,
20+
):
1521
"""
1622
C2888569 - Verify Autofill functionality when selecting an entry from the dropdown for tele/email fields
1723
"""
18-
# Instantiate objects
19-
address_autofill = AddressFill(driver)
20-
address_autofill_popup = AutofillPopup(driver)
21-
util = Utilities()
2224

2325
# Create fake data and fill it in
2426
address_autofill.open()
2527
address_autofill_data = util.fake_autofill_data(region)
2628
address_autofill.save_information_basic(address_autofill_data)
2729

2830
# Click the "Save" button
29-
address_autofill_popup.click_doorhanger_button("save")
31+
autofill_popup.click_doorhanger_button("save")
3032

3133
# Double inside phone field and select a saved address entry from the dropdown
3234
address_autofill.double_click("form-field", labels=["tel"])
3335

3436
# 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+
first_item = autofill_popup.get_nth_element(1)
38+
autofill_popup.click_on(first_item)
3739

3840
# Verify autofill data
3941
address_autofill.verify_autofill_data(address_autofill_data, region, util)
4042

4143
# Double inside phone field and select clear form autofill
4244
address_autofill.double_click("form-field", labels=["tel"])
43-
address_autofill_popup.click_clear_form_option()
45+
autofill_popup.click_clear_form_option()
4446

4547
# Double inside email field and select a saved address entry from the dropdown
4648
address_autofill.double_click("form-field", labels=["email"])
4749

4850
# 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+
first_item = autofill_popup.get_nth_element(1)
52+
autofill_popup.click_on(first_item)
5153

5254
# Verify autofill data
5355
address_autofill.verify_autofill_data(address_autofill_data, region, util)

l10n_CM/Unified/test_demo_ad_email_phone_captured_in_doorhanger_and_stored.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,12 @@ def test_demo_ad_email_phone_captured_in_doorhanger_and_stored(
3838

3939
# containing phone field
4040
expected_phone = address_autofill_data.telephone
41-
# Skip verification if phone number isn't provided
42-
if expected_phone:
43-
with driver.context(driver.CONTEXT_CHROME):
44-
actual_phone = autofill_popup.get_element("address-doorhanger-phone").text
45-
normalize_expected = util.normalize_regional_phone_numbers(
46-
expected_phone, region
47-
)
48-
normalized_actual = util.normalize_regional_phone_numbers(actual_phone, region)
49-
assert normalized_actual == normalize_expected, (
50-
f"Phone number mismatch for {region} | Expected: {normalize_expected}, Got: {normalized_actual}"
51-
)
41+
actual_phone = autofill_popup.get_cc_doorhanger_data("address-doorhanger-phone")
42+
normalize_expected = util.normalize_regional_phone_numbers(expected_phone, region)
43+
normalized_actual = util.normalize_regional_phone_numbers(actual_phone, region)
44+
assert normalized_actual == normalize_expected, (
45+
f"Phone number mismatch for {region} | Expected: {normalize_expected}, Got: {normalized_actual}"
46+
)
5247

5348
# Click the "Save" button
5449
autofill_popup.click_doorhanger_button("save")

l10n_CM/Unified/test_demo_ad_verify_new_address_added.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def region():
2020
@pytest.fixture()
2121
def add_prefs(region: str):
2222
return [
23-
("browser.search.region", region),
2423
("extensions.formautofill.creditCards.supportedCountries", region),
2524
("extensions.formautofill.addresses.supported", "on"),
2625
]

l10n_CM/Unified/test_demo_ad_yellow_highlight.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,30 @@ def test_case():
1212

1313

1414
def test_address_yellow_highlight_on_name_organization_fields(
15-
driver: Firefox, region: str
15+
driver: Firefox,
16+
region: str,
17+
util: Utilities,
18+
address_autofill: AddressFill,
19+
autofill_popup: AutofillPopup,
1620
):
1721
"""
1822
C2888559 - Verify the yellow highlight appears on autofilled fields for name and organization.
1923
"""
2024

21-
# Instantiate objects
22-
address_autofill = AddressFill(driver)
23-
address_autofill_popup = AutofillPopup(driver)
24-
util = Utilities()
25-
2625
# Create fake data and fill it in
2726
address_autofill.open()
2827
address_autofill_data = util.fake_autofill_data(region)
2928
address_autofill.save_information_basic(address_autofill_data)
3029

3130
# Click the "Save" button
32-
address_autofill_popup.click_doorhanger_button("save")
31+
autofill_popup.click_doorhanger_button("save")
3332

3433
# Double click inside phone field and select a saved address entry from the dropdown
3534
address_autofill.double_click("form-field", labels=["name"])
3635

3736
# Click on the first element from the autocomplete dropdown
38-
first_item = address_autofill_popup.get_nth_element(1)
39-
address_autofill_popup.click_on(first_item)
37+
first_item = autofill_popup.get_nth_element(1)
38+
autofill_popup.click_on(first_item)
4039

4140
# Verify the name and organization fields are highlighted
4241
address_autofill.verify_field_yellow_highlights(

l10n_CM/Unified/test_demo_cc_add_new_credit_card.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pytest
44
from selenium.webdriver import Firefox
55

6+
from l10n_CM.Unified.conftest import region
67
from modules.page_object import AboutPrefs
78
from modules.util import Utilities
89

@@ -28,7 +29,7 @@ def test_create_new_cc_profile(
2829
about_prefs_privacy.switch_to_saved_payments_popup_iframe()
2930

3031
# Save CC information using fake data
31-
credit_card_sample_data = util.fake_credit_card_data()
32+
credit_card_sample_data = util.fake_credit_card_data(region)
3233

3334
# Add a new CC profile
3435
about_prefs.click_on("panel-popup-button", labels=["autofill-manage-add-button"])

l10n_CM/Unified/test_demo_cc_clear_form.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def test_case():
1313

1414
def test_cc_clear_form(
1515
driver: Firefox,
16+
region: str,
1617
util: Utilities,
1718
autofill_popup: AutofillPopup,
1819
about_prefs_privacy: AboutPrefs,
@@ -28,7 +29,7 @@ def test_cc_clear_form(
2829
about_prefs_privacy.open()
2930
about_prefs_privacy.switch_to_saved_payments_popup_iframe()
3031

31-
credit_card_sample_data = util.fake_credit_card_data()
32+
credit_card_sample_data = util.fake_credit_card_data(region)
3233
about_prefs.click_on("panel-popup-button", labels=["autofill-manage-add-button"])
3334
about_prefs_privacy.fill_cc_panel_information(credit_card_sample_data)
3435

l10n_CM/Unified/test_demo_cc_doorhanger_data_is_stored_in_about_prefs.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
1-
import time
2-
31
import pytest
42
from selenium.webdriver import Firefox
53

4+
from l10n_CM.Unified.conftest import region
65
from modules.browser_object_autofill_popup import AutofillPopup
76
from modules.page_object_autofill import CreditCardFill
87
from modules.page_object_prefs import AboutPrefs
9-
from modules.util import BrowserActions, Utilities
8+
from modules.util import Utilities
109

1110

1211
@pytest.fixture()
1312
def test_case():
1413
return "2886597"
1514

1615

17-
def test_demo_cc_data_captured_in_doorhanger_and_stored(driver: Firefox, region: str):
16+
def test_demo_cc_data_captured_in_doorhanger_and_stored(
17+
driver: Firefox,
18+
region: str,
19+
credit_card_fill_obj: CreditCardFill,
20+
autofill_popup: AutofillPopup,
21+
util: Utilities,
22+
about_prefs_privacy: AboutPrefs,
23+
):
1824
"""
1925
C2889999 - Verify credit card data is captured in the Capture Doorhanger and stored in about:preferences
2026
"""
21-
22-
# Instantiate objects
23-
credit_card_fill_obj = CreditCardFill(driver)
24-
autofill_popup_obj = AutofillPopup(driver)
25-
util = Utilities()
26-
browser_action_obj = BrowserActions(driver)
27-
2827
# Navigate to page
2928
credit_card_fill_obj.open()
3029

3130
# Fill data
32-
credit_card_sample_data = util.fake_credit_card_data()
31+
credit_card_sample_data = util.fake_credit_card_data(region)
3332
credit_card_fill_obj.fill_credit_card_info(credit_card_sample_data)
3433

3534
# The "Save credit card?" doorhanger is displayed
36-
assert autofill_popup_obj.element_visible("doorhanger-save-button"), (
35+
assert autofill_popup.element_visible("doorhanger-save-button"), (
3736
"Credit card save doorhanger is not visible"
3837
)
3938

4039
# Verify Credit Card Doorhanger Data
41-
doorhanger_text = autofill_popup_obj.get_cc_doorhanger_data("cc-doorhanger-data")
40+
doorhanger_text = autofill_popup.get_cc_doorhanger_data("cc-doorhanger-data")
4241
assert credit_card_sample_data.card_number[-4:] in doorhanger_text, (
4342
f"Expected last 4 digits '{credit_card_sample_data.card_number[-4:]}' but not found."
4443
)
@@ -50,17 +49,18 @@ def test_demo_cc_data_captured_in_doorhanger_and_stored(driver: Firefox, region:
5049
)
5150

5251
# Click the "Save" button using click_doorhanger_button
53-
autofill_popup_obj.click_doorhanger_button("save")
52+
autofill_popup.click_doorhanger_button("save")
5453

5554
# Navigate to about:preferences#privacy => "Autofill" section
56-
about_prefs = AboutPrefs(driver, category="privacy").open()
57-
iframe = about_prefs.get_saved_payments_popup_iframe()
58-
browser_action_obj.switch_to_iframe_context(iframe)
55+
about_prefs_privacy.open()
56+
about_prefs_privacy.switch_to_saved_payments_popup_iframe()
5957

6058
# Get stored values
6159
elements = [
6260
x.strip()
63-
for x in about_prefs.get_element("saved-credit-cards-values").text.split(",")
61+
for x in about_prefs_privacy.get_element(
62+
"saved-credit-cards-values"
63+
).text.split(",")
6464
]
6565

6666
# Validate stored values match expected values

l10n_CM/Unified/test_demo_cc_doorhanger_shown_on_valid_credit_card_submission.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_cc_check_door_hanger_is_displayed(
2525
credit_card_fill_obj.open()
2626

2727
# Fill data
28-
credit_card_sample_data = util.fake_credit_card_data()
28+
credit_card_sample_data = util.fake_credit_card_data(region)
2929
credit_card_fill_obj.fill_credit_card_info(credit_card_sample_data)
3030

3131
# Check if an element from the door hanger is visible

0 commit comments

Comments
 (0)