Skip to content

Philimon/live poc #558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9fc4863
inital progress on poc
philimon-reset Apr 14, 2025
ebfa170
continued efforts with live site POC
philimon-reset Apr 15, 2025
b4151a0
broken change to ignore doorhanger
philimon-reset Apr 17, 2025
7c25d2d
base structure for live testing set for walmart address page
philimon-reset Apr 17, 2025
de4d00c
amazon address field working
philimon-reset Apr 23, 2025
98bb557
proof of concept complete
philimon-reset Apr 23, 2025
e36f9fa
Merge branch 'main' into philimon/live-poc
philimon-reset Apr 23, 2025
557eb98
fix test create address profile
philimon-reset Apr 23, 2025
f8003e3
unfortunate mistake
philimon-reset Apr 23, 2025
2be9c8a
live site access changed(only relevant for my local testing)
philimon-reset Apr 24, 2025
01f03bc
further work to support DE and FR regions and clean up
philimon-reset Apr 24, 2025
b6ee055
webserver implemented
philimon-reset Apr 29, 2025
a422504
amazon_ad minify
philimon-reset Apr 29, 2025
d96ac86
Merge branch 'main' into philimon/live-poc
philimon-reset Apr 29, 2025
5ebb181
region divide added
philimon-reset Apr 29, 2025
99d6611
canada address page for amazon added
philimon-reset Apr 29, 2025
4817d35
fix conftest
philimon-reset Apr 29, 2025
f3774b6
remove loggin
philimon-reset Apr 29, 2025
786a2f8
l10n clean up
philimon-reset Apr 29, 2025
156ee2b
extra field for credit card base class.
philimon-reset Apr 29, 2025
3151c7b
revert change
philimon-reset Apr 29, 2025
f05165c
remove unnessary files
philimon-reset Apr 29, 2025
fa76477
added amazon canada fix
philimon-reset Apr 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
proof of concept complete
  • Loading branch information
philimon-reset committed Apr 23, 2025
commit 98bb55722c56c2818ef74562018b6d7eac40a497
73 changes: 49 additions & 24 deletions l10n_CM/Unified/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@

@pytest.fixture()
def region():
return os.environ.get("FX_REGION", "US")
return os.environ.get("FX_REGION")


@pytest.fixture()
def live_site():
return os.environ.get("FX_SITE")


@pytest.fixture()
Expand All @@ -37,36 +42,50 @@ def prefs_list(add_to_prefs_list: List[tuple[str, str | bool]], region: str):


@pytest.fixture()
def site_data():
# live_site = os.environ.get("FX_SITE", None)
# un comment to test a live site form
live_site = "amazon/amazon_ad"
def ad_site_data(live_site):
ad_live_site = f"{live_site}/{live_site}_ad"
if live_site:
path_to_site = parent_dir + "/constants/"
with open(path_to_site + live_site + ".json", "r") as fp:
with open(path_to_site + ad_live_site + ".json", "r") as fp:
live_site_data = load(fp)
return live_site_data
return {}


@pytest.fixture()
def url_template(site_data):
return site_data.get("url", None)
def ad_url_template(ad_site_data):
return ad_site_data.get("url", None)


@pytest.fixture()
def cc_site_data(live_site):
cc_live_site = f"{live_site}/{live_site}_cc"
if live_site:
path_to_site = parent_dir + "/constants/"
with open(path_to_site + cc_live_site + ".json", "r") as fp:
live_site_data = load(fp)
return live_site_data
return {}


@pytest.fixture()
def fields(site_data):
return site_data.get("fields", None)
def cc_url_template(cc_site_data):
return cc_site_data.get("url", None)


@pytest.fixture()
def field_mapping(site_data):
return site_data.get("field_mapping", None)
def ad_form_field(ad_site_data):
selector = ad_site_data.get("form_field", None)
return (
{"form-field": {"selectorData": selector, "strategy": "css", "groups": []}}
if selector
else {}
)


@pytest.fixture()
def form_field(site_data):
selector = site_data.get("form_field", None)
def cc_form_field(cc_site_data):
selector = cc_site_data.get("form_field", None)
return (
{"form-field": {"selectorData": selector, "strategy": "css", "groups": []}}
if selector
Expand All @@ -75,20 +94,26 @@ def form_field(site_data):


@pytest.fixture()
def address_autofill(driver, url_template, fields, field_mapping, form_field):
def address_autofill(driver, ad_site_data, ad_form_field):
af = AddressFill(
driver, url_template=url_template, field_mapping=field_mapping, fields=fields
driver,
url_template=ad_site_data.get("url"),
field_mapping=ad_site_data.get("field_mapping"),
fields=ad_site_data.get("fields"),
)
af.elements |= form_field
af.elements |= ad_form_field
return af


@pytest.fixture()
def credit_card_autofill(driver, url_template, fields, field_mapping, form_field):
def credit_card_autofill(driver, cc_site_data, cc_form_field):
cf = CreditCardFill(
driver, url_template=url_template, field_mapping=field_mapping, fields=fields
driver,
url_template=cc_site_data.get("url"),
field_mapping=cc_site_data.get("field_mapping"),
fields=cc_site_data.get("fields"),
)
cf.elements |= form_field
cf.elements |= cc_form_field
return cf


Expand Down Expand Up @@ -150,27 +175,27 @@ def populate_saved_addresses(

@pytest.fixture()
def fill_and_save_address(
address_autofill: AddressFill, url_template: str | None, region: str, request
address_autofill: AddressFill, ad_site_data, region: str, request
):
"""
Fixture to populate address entry depending on whether the url is a live site.
If live site, populate data through about:prefs, if not fill directly through page.
"""
if url_template:
if ad_site_data.get("url"):
return request.getfixturevalue("populate_saved_addresses")
address_autofill.open()
return address_autofill.fill_and_save(region)


@pytest.fixture()
def fill_and_save_payments(
credit_card_autofill: CreditCardFill, url_template: str | None, region: str, request
credit_card_autofill: CreditCardFill, cc_site_data, region: str, request
):
"""
Fixture to populate cc entry depending on whether the url is a live site.
If live site, populate data through about:prefs, if not fill directly through page.
"""
if url_template:
if cc_site_data.get("url"):
return request.getfixturevalue("populate_saved_payments")
credit_card_autofill.open()
return credit_card_autofill.fill_and_save(region)
3 changes: 3 additions & 0 deletions l10n_CM/Unified/test_demo_ad_1a_dropdown_name_org_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def test_dropdown_presence_name_organization(
# open address filling url page
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

# Verify that the name and organization fields have the autofill dropdown present
fields_to_test = ["name", "given_name", "family_name", "organization"]

Expand Down
3 changes: 3 additions & 0 deletions l10n_CM/Unified/test_demo_ad_1b_dropdown_address_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def test_dropdown_presence_address_field(
# open address filling url page
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

fields_to_test = [
"street_address",
"address_level_2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def test_dropdown_presence_email_phone_field(
# Open autofill page
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

fields_to_test = ["email", "telephone"]

address_autofill.verify_field_autofill_dropdown(
Expand Down
3 changes: 3 additions & 0 deletions l10n_CM/Unified/test_demo_ad_2a_preview_name_org_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def test_demo_ad_hover_name_org(
# Create fake data
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

# created fake data
autofill_data = fill_and_save_address

Expand Down
3 changes: 3 additions & 0 deletions l10n_CM/Unified/test_demo_ad_2b_preview_address_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def test_hover_address_is_previewed(
# Create fake data
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

# created fake data
autofill_data = fill_and_save_address

Expand Down
3 changes: 3 additions & 0 deletions l10n_CM/Unified/test_demo_ad_2c_preview_phone_email_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ def test_hover_email_and_phone_autofill_preview(
# Create fake data
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

# created fake data
autofill_data = fill_and_save_address

Expand Down
3 changes: 3 additions & 0 deletions l10n_CM/Unified/test_demo_ad_3a_autofill_address_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def test_demo_ad_autofill_address_fields(
# Create fake data
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

# created fake data
autofill_data = fill_and_save_address

Expand Down
3 changes: 3 additions & 0 deletions l10n_CM/Unified/test_demo_ad_3b_autofill_name_org_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def test_demo_ad_autofill_name_org(
# Create fake data
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

# created fake data
autofill_data = fill_and_save_address

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def test_demo_ad_autofill_phone_email(
# Create fake data
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

# created fake data
autofill_data = fill_and_save_address

Expand Down
3 changes: 3 additions & 0 deletions l10n_CM/Unified/test_demo_ad_4a_highlight_name_org_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def test_address_yellow_highlight_on_name_organization_fields(
# Create fake data and fill it in
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

# Double click inside name field and select a saved address entry from the dropdown
if address_autofill.is_field_present("name"):
address_autofill.click_form_field("name")
Expand Down
3 changes: 3 additions & 0 deletions l10n_CM/Unified/test_demo_ad_4b_highlight_address_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def test_address_yellow_highlight_address_fields(
# Create fake data and fill it in
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

# Double click inside name field and select a saved address entry from the dropdown
address_autofill.click_form_field("street_address")
autofill_popup.ensure_autofill_dropdown_visible()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def test_address_yellow_highlight_address_fields(
# Create fake data and fill it in
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

# Double click inside name field and select a saved address entry from the dropdown
address_autofill.click_form_field("email")
autofill_popup.ensure_autofill_dropdown_visible()
Expand Down
3 changes: 3 additions & 0 deletions l10n_CM/Unified/test_demo_ad_5a_clear_name_org_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def test_demo_ad_clear_name_org(
# Create fake data and fill it in
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

# List of field labels to be autofilled and verified
fields_to_test = ["name", "given_name", "family_name", "organization"]

Expand Down
3 changes: 3 additions & 0 deletions l10n_CM/Unified/test_demo_ad_5b_clear_address_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def test_demo_ad_clear_address_fields(
# Create fake data and fill it in
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

# List of field labels to be autofilled and verified
fields_to_test = [
"street_address",
Expand Down
3 changes: 3 additions & 0 deletions l10n_CM/Unified/test_demo_ad_5c_clear_phone_email_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def test_demo_ad_clear_tel_email(
# Create fake data and fill it in
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

# List of field labels to be autofilled and verified
fields_to_test = ["email", "telephone"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ def test_address_doorhanger_displayed_after_entering_valid_address(
address_autofill: AddressFill,
util: Utilities,
autofill_popup: AutofillPopup,
url_template: str,
ad_url_template: str,
):
"""
C2886581 - Verify the Capture Door hanger is displayed after entering valid Address data
"""
if not url_template:
if not ad_url_template:
# Create fake data and fill it in
address_autofill.open()
# scroll to first form field
address_autofill.scroll_to_form_field()

address_autofill.fill_and_save(region, door_hanger=False)

# Check "Save Address?" door hanger appears in the Address bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ def test_demo_ad_name_org_captured_in_doorhanger_and_stored(
util: Utilities,
autofill_popup: AutofillPopup,
about_prefs_privacy: AboutPrefs,
url_template: str,
ad_url_template: str,
):
"""
C2888701 - Verify name/org fields are captured in the Capture Doorhanger and stored in about:preferences
"""
if not url_template:
if not ad_url_template:
# Create fake data and fill it in
address_autofill.open()
# scroll to first form field
address_autofill.scroll_to_form_field()

address_autofill_data = address_autofill.fill_and_save(
region, door_hanger=False
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ def test_demo_ad_address_data_captured_in_doorhanger_and_stored(
util: Utilities,
autofill_popup: AutofillPopup,
about_prefs_privacy: AboutPrefs,
url_template: str,
ad_url_template: str,
):
"""
C2888703 - Verify Address data are captured in the Capture Doorhanger and stored in about:preferences
"""
if not url_template:
if not ad_url_template:
# Create fake data and fill it in
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

address_autofill_data = address_autofill.fill_and_save(
region, door_hanger=False
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ def test_demo_ad_email_phone_captured_in_doorhanger_and_stored(
util: Utilities,
autofill_popup: AutofillPopup,
about_prefs_privacy: AboutPrefs,
url_template: str,
ad_url_template: str,
):
"""
C2888704 - Verify tele/email data are captured in the Capture Doorhanger and stored in about:preferences
"""
if not url_template:
if not ad_url_template:
# Create fake data and fill it in
address_autofill.open()

# scroll to first form field
address_autofill.scroll_to_form_field()

address_autofill_data = address_autofill.fill_and_save(
region, door_hanger=False
)
Expand Down
7 changes: 5 additions & 2 deletions l10n_CM/Unified/test_demo_cc_1_dropdown.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from selenium.webdriver import Firefox
from selenium.webdriver import ActionChains, Firefox

from modules.browser_object_autofill_popup import AutofillPopup
from modules.classes.credit_card import CreditCardBase
Expand All @@ -19,13 +19,16 @@ def test_dropdown_presence_credit_card(
autofill_popup: AutofillPopup,
about_prefs_privacy: AboutPrefs,
credit_card_autofill: CreditCardFill,
populate_saved_payments: CreditCardBase,
fill_and_save_payments: CreditCardBase,
):
"""
C2886598 - Verify autofill dropdown is displayed only for the eligible fields after a credit card is saved
"""
# Open credit card form page
credit_card_autofill.open()

# scroll to first form field
credit_card_autofill.scroll_to_form_field()

# Verify autofill dropdown is displayed only for the eligible fields
credit_card_autofill.verify_field_autofill_dropdown()
Loading
Loading