Skip to content

Commit 83206b4

Browse files
Hani YacoubHani Yacoub
authored andcommitted
merge main
2 parents 1e615fb + be49f08 commit 83206b4

11 files changed

+221
-8
lines changed

SELECTOR_INFO.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,48 @@ Description: Save address doorhanger organization section
13811381
Location: Address bar
13821382
Path to .json: modules/data/autofill_popup.components.json
13831383
```
1384+
```
1385+
Selector Name: address-doorhanger-street
1386+
Selector Data: "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(3) span"
1387+
Description: Save address doorhanger street address section
1388+
Location: Address bar
1389+
Path to .json: modules/data/autofill_popup.components.json
1390+
```
1391+
```
1392+
Selector Name: address-doorhanger-city
1393+
Selector Data: "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-of-type(1)"
1394+
Description: Save address doorhanger city section
1395+
Location: Address bar
1396+
Path to .json: modules/data/autofill_popup.components.json
1397+
```
1398+
```
1399+
Selector Name: address-doorhanger-state
1400+
Selector Data: "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-of-type(3)"
1401+
Description: Save address doorhanger state section
1402+
Location: Address bar
1403+
Path to .json: modules/data/autofill_popup.components.json
1404+
```
1405+
```
1406+
Selector Name: address-doorhanger-zip
1407+
Selector Data: "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-of-type(5)"
1408+
Description: Save address doorhanger zip section for US and CA
1409+
Location: Address bar
1410+
Path to .json: modules/data/autofill_popup.components.json
1411+
```
1412+
```
1413+
Selector Name: address-doorhanger-zip-other
1414+
Selector Data: "selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-of-type(3)",
1415+
Description: Save address doorhanger zip section for other regions
1416+
Location: Address bar
1417+
Path to .json: modules/data/autofill_popup.components.json
1418+
```
1419+
```
1420+
Selector Name: address-doorhanger-country
1421+
Selector Data: "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(5) span"
1422+
Description: Save address doorhanger country section
1423+
Location: Address bar
1424+
Path to .json: modules/data/autofill_popup.components.json
1425+
```
13841426
#### context_menu
13851427
```
13861428
Selector Name: context-menu-search-selected-text
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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.page_object_prefs import AboutPrefs
7+
from modules.util import Utilities, BrowserActions
8+
9+
10+
11+
@pytest.fixture()
12+
def test_case():
13+
return "2888703"
14+
15+
16+
def test_demo_ad_address_data_captured_in_doorhanger_and_stored(driver: Firefox, region: str):
17+
"""
18+
C2888703 - Verify Address data are captured in the Capture Doorhanger and stored in about:preferences
19+
"""
20+
# instantiate objects
21+
address_autofill = AddressFill(driver)
22+
address_autofill_popup = AutofillPopup(driver)
23+
util = Utilities()
24+
browser_action_obj = BrowserActions(driver)
25+
26+
# create fake data and fill it in
27+
address_autofill.open()
28+
address_autofill_data = util.fake_autofill_data(region)
29+
address_autofill.save_information_basic(address_autofill_data)
30+
31+
# The "Save address?" doorhanger is displayed
32+
address_autofill_popup.element_visible("address-save-doorhanger")
33+
34+
# containing Street Address field
35+
expected_street_add = address_autofill_data.street_address
36+
address_autofill_popup.element_has_text("address-doorhanger-street", expected_street_add)
37+
38+
# containing City field
39+
expected_city = address_autofill_data.address_level_2
40+
address_autofill_popup.element_has_text("address-doorhanger-city", expected_city)
41+
42+
expected_state = address_autofill_data.address_level_1
43+
if region not in ["FR", "DE"]:
44+
state_abbreviation = util.get_state_province_abbreviation(expected_state)
45+
address_autofill_popup.element_has_text("address-doorhanger-state", state_abbreviation)
46+
47+
# Verify Zip Code field (Different selector for DE/FR)
48+
expected_zip = address_autofill_data.postal_code
49+
zip_selector = "address-doorhanger-zip-other" if region in ["FR", "DE"] else "address-doorhanger-zip"
50+
address_autofill_popup.element_has_text(zip_selector, expected_zip)
51+
52+
# containing Country field
53+
expected_country = address_autofill_data.country
54+
address_autofill_popup.element_has_text("address-doorhanger-country", expected_country)
55+
56+
# Click the "Save" button
57+
address_autofill_popup.click_doorhanger_button("save")
58+
59+
# 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)
63+
64+
# Verify saved addresses
65+
elements = about_prefs.get_elements("saved-addresses-values")
66+
67+
# Expected values for verification
68+
expected_values = [expected_street_add, expected_city, expected_zip, expected_country]
69+
if region not in ["FR", "DE"]:
70+
expected_values.insert(2, expected_state)
71+
72+
# Check if all expected values exist in any saved address
73+
found_address_data = any(
74+
all(value in element.text for value in expected_values)
75+
for element in elements
76+
)
77+
assert found_address_data, "Street, city, state (if applicable), zip, or country were not found in any of the address entries!"

l10n_CM/region/CA.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"test_demo_ad_doorhanger_shown_on_valid_address_submission.py",
77
"test_demo_ad_email_phone_captured_in_doorhanger_and_stored.py",
88
"test_demo_ad_name_org_captured_in_doorhanger_and_stored.py",
9+
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py",
910
"test_demo_cc_dropdown-presence.py"
1011
]
1112
}

l10n_CM/region/DE.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"test_demo_ad_doorhanger_shown_on_valid_address_submission.py",
77
"test_demo_ad_email_phone_captured_in_doorhanger_and_stored.py",
88
"test_demo_ad_name_org_captured_in_doorhanger_and_stored.py",
9-
"test_demo_cc_dropdown-presence.py"
9+
"test_demo_cc_dropdown-presence.py",
10+
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py"
1011
]
1112
}

l10n_CM/region/FR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
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_email_phone_captured_in_doorhanger_and_stored.py"
9+
"test_demo_ad_email_phone_captured_in_doorhanger_and_stored.py",
10+
"test_demo_cc_dropdown-presence.py"
1011
]
1112
}

l10n_CM/region/US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
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_email_phone_captured_in_doorhanger_and_stored.py"
9+
"test_demo_ad_email_phone_captured_in_doorhanger_and_stored.py",
10+
"test_demo_cc_dropdown-presence.py"
1011
]
1112
}

modules/data/autofill_popup.components.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,42 @@
107107
"selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(2) span",
108108
"strategy": "css",
109109
"groups": []
110+
},
111+
112+
"address-doorhanger-street": {
113+
"selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(3) span",
114+
"strategy": "css",
115+
"groups": []
116+
},
117+
118+
"address-doorhanger-city": {
119+
"selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-of-type(1)",
120+
"strategy": "css",
121+
"groups": []
122+
},
123+
124+
"address-doorhanger-state": {
125+
"selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-of-type(3)",
126+
"strategy": "css",
127+
"groups": []
128+
},
129+
130+
"address-doorhanger-zip": {
131+
"selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-of-type(5)",
132+
"strategy": "css",
133+
"groups": []
134+
},
135+
136+
"address-doorhanger-zip-other": {
137+
"selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-of-type(3)",
138+
"strategy": "css",
139+
"groups": []
140+
},
141+
142+
"address-doorhanger-country": {
143+
"selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(5) span",
144+
"strategy": "css",
145+
"groups": []
110146
}
111147
}
112148

modules/page_object_prefs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,14 @@ def click_popup_panel_button(self, field: str) -> BasePage:
394394
self.get_element("panel-popup-button", labels=[field]).click()
395395
return self
396396

397-
def select_https_only_setting(self, option_id: "HttpsOnlyStatus") -> BasePage:
397+
def select_https_only_setting(self, option_id: HttpsOnlyStatus) -> BasePage:
398398
"""
399399
Click the HTTPS Only option given
400400
"""
401401
self.find_in_settings("HTTPS")
402-
self.element_clickable(option_id)
403-
self.click_on(option_id)
404-
self.element_attribute_contains(option_id, "checked", "")
402+
self.element_clickable(str(option_id))
403+
self.click_on(str(option_id))
404+
self.element_attribute_contains(str(option_id), "checked", "")
405405
return self
406406

407407
def set_default_zoom_level(self, zoom_percentage: int) -> BasePage:

modules/testrail.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,21 @@ def get_test_case(self, case_id):
160160
"""Get a given Test Case"""
161161
return self.client.send_get(f"get_case/{case_id}")
162162

163+
def update_cases_in_suite(self, suite_id, case_ids, **kwargs):
164+
"""Given a suite and a list of test cases, update all listed
165+
test cases according to keyword args"""
166+
if not kwargs:
167+
return None
168+
return self.client.send_post(
169+
f"update_cases/{suite_id}", {"case_ids": case_ids, **kwargs}
170+
)
171+
172+
def update_test_case(self, case_id, **kwargs):
173+
"""Given a test case id, update according to keyword args"""
174+
if not kwargs:
175+
return None
176+
return self.client.send_post(f"update_case/{case_id}", **kwargs)
177+
163178
def create_test_run_on_plan_entry(
164179
self, plan_id, entry_id, config_ids, description=None, case_ids=None
165180
):
@@ -235,6 +250,14 @@ def matching_plan_in_milestone(self, testrail_project_id, milestone_id, plan_nam
235250
return self._get_full_plan(plan.get("id"))
236251
return None
237252

253+
def matching_custom_field(self, name):
254+
"""Given a name, return the case_field object that matches (name or label)"""
255+
custom_fields = self._get_case_fields()
256+
for field in custom_fields:
257+
if name in field.get("name") or name in field.get("label"):
258+
return field
259+
return None
260+
238261
def create_new_plan(
239262
self,
240263
testrail_project_id,
@@ -448,6 +471,9 @@ def _get_plans_in_milestone(self, testrail_project_id, milestone_id):
448471
def _get_full_plan(self, plan_id):
449472
return self.client.send_get(f"get_plan/{plan_id}")
450473

474+
def _get_case_fields(self):
475+
return self.client.send_get("get_case_fields")
476+
451477
def _retry_api_call(self, api_call, *args, max_retries=3, delay=5):
452478
"""
453479
Retries the given API call up to max_retries times with a delay between attempts.

modules/util.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,34 @@ def get_all_attributes(self, driver: Firefox, item: WebElement) -> str:
394394
ret_val += f"{attribute}: {value}\n"
395395
return ret_val
396396

397+
def get_state_province_abbreviation(self, full_name: str) -> str:
398+
"""
399+
Returns the abbreviation for a given state, province, or region full name.
400+
401+
:param full_name: The full name of the state, province, or region.
402+
:return: The corresponding abbreviation or "Not Found" if not in the dictionary.
403+
"""
404+
state_province_abbr = {
405+
# US States
406+
"Alabama": "AL", "Alaska": "AK", "Arizona": "AZ", "Arkansas": "AR", "California": "CA",
407+
"Colorado": "CO", "Connecticut": "CT", "Delaware": "DE", "Florida": "FL", "Georgia": "GA",
408+
"Hawaii": "HI", "Idaho": "ID", "Illinois": "IL", "Indiana": "IN", "Iowa": "IA",
409+
"Kansas": "KS", "Kentucky": "KY", "Louisiana": "LA", "Maine": "ME", "Maryland": "MD",
410+
"Massachusetts": "MA", "Michigan": "MI", "Minnesota": "MN", "Mississippi": "MS", "Missouri": "MO",
411+
"Montana": "MT", "Nebraska": "NE", "Nevada": "NV", "New Hampshire": "NH", "New Jersey": "NJ",
412+
"New Mexico": "NM", "New York": "NY", "North Carolina": "NC", "North Dakota": "ND", "Ohio": "OH",
413+
"Oklahoma": "OK", "Oregon": "OR", "Pennsylvania": "PA", "Rhode Island": "RI", "South Carolina": "SC",
414+
"South Dakota": "SD", "Tennessee": "TN", "Texas": "TX", "Utah": "UT", "Vermont": "VT",
415+
"Virginia": "VA", "Washington": "WA", "West Virginia": "WV", "Wisconsin": "WI", "Wyoming": "WY",
416+
417+
# Canadian Provinces
418+
"Alberta": "AB", "British Columbia": "BC", "Manitoba": "MB", "New Brunswick": "NB",
419+
"Newfoundland and Labrador": "NL", "Nova Scotia": "NS", "Ontario": "ON", "Prince Edward Island": "PE",
420+
"Quebec": "QC", "Saskatchewan": "SK", "Northwest Territories": "NT", "Nunavut": "NU", "Yukon": "YT",
421+
}
422+
423+
return state_province_abbr.get(full_name, "Not Found")
424+
397425

398426
class BrowserActions:
399427
"""

0 commit comments

Comments
 (0)