Skip to content

Commit 5069961

Browse files
Hani YacoubHani Yacoub
authored andcommitted
Merge main
2 parents 9997061 + b43de03 commit 5069961

File tree

13 files changed

+169
-4
lines changed

13 files changed

+169
-4
lines changed

SELECTOR_INFO.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,20 @@ Location: Address bar
13541354
Path to .json: modules/data/autofill_popup.components.json
13551355
```
13561356
```
1357+
Selector Name: address-doorhanger-name
1358+
Selector Data: "div.address-save-update-row-container:nth-of-type(1) div p:first-of-type span"
1359+
Description: Save address doorhanger name section
1360+
Location: Address bar
1361+
Path to .json: modules/data/autofill_popup.components.json
1362+
```
1363+
```
1364+
Selector Name: address-doorhanger-org
1365+
Selector Data: "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(2) span"
1366+
Description: Save address doorhanger organization section
1367+
Location: Address bar
1368+
Path to .json: modules/data/autofill_popup.components.json
1369+
```
1370+
```
13571371
Selector Name: address-doorhanger-street
13581372
Selector Data: "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(3) span"
13591373
Description: Save address doorhanger street address section
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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 BrowserActions, Utilities
9+
10+
11+
@pytest.fixture()
12+
def test_case():
13+
return "2888701"
14+
15+
16+
def test_demo_ad_name_org_captured_in_doorhanger_and_stored(
17+
driver: Firefox, region: str
18+
):
19+
"""
20+
C2888701 - Verify name/org fields are captured in the Capture Doorhanger and stored in about:preferences
21+
"""
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+
32+
# create fake data and fill it in
33+
address_autofill.open()
34+
address_autofill_data = util.fake_autofill_data(region)
35+
address_autofill.save_information_basic(address_autofill_data)
36+
37+
# The "Save address?" doorhanger is displayed
38+
address_autofill_popup.element_visible("address-save-doorhanger")
39+
40+
# containing name field
41+
expected_name = address_autofill_data.name
42+
address_autofill_popup.element_has_text("address-doorhanger-name", expected_name)
43+
44+
# containing org field
45+
expected_org = address_autofill_data.organization
46+
address_autofill_popup.element_has_text("address-doorhanger-org", expected_org)
47+
48+
# Click the "Save" button
49+
address_autofill_popup.click_doorhanger_button("save")
50+
51+
# Navigate to about:preferences#privacy => "Autofill" section
52+
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)
55+
56+
# The address saved in step 2 is listed in the "Saved addresses" modal: name and organization
57+
elements = about_prefs.get_elements("saved-addresses-values")
58+
expected_values = [expected_name, expected_org]
59+
found_name_org = any(
60+
all(value in element.text for value in expected_values) for element in elements
61+
)
62+
assert (
63+
found_name_org
64+
), "Name or organization 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
@@ -4,6 +4,7 @@
44
"test_demo_cc_doorhanger_shown_on_valid_credit_card_submission.py",
55
"test_demo_cc_add_new_credit_card.py",
66
"test_demo_ad_doorhanger_shown_on_valid_address_submission.py",
7+
"test_demo_ad_name_org_captured_in_doorhanger_and_stored.py",
78
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py"
89
]
910
}

l10n_CM/region/DE.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"test_demo_cc_doorhanger_shown_on_valid_credit_card_submission.py",
55
"test_demo_cc_add_new_credit_card.py",
66
"test_demo_ad_doorhanger_shown_on_valid_address_submission.py",
7+
"test_demo_ad_name_org_captured_in_doorhanger_and_stored.py",
78
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py"
89
]
910
}

l10n_CM/region/FR.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"test_demo_cc_doorhanger_shown_on_valid_credit_card_submission.py",
55
"test_demo_cc_add_new_credit_card.py",
66
"test_demo_ad_doorhanger_shown_on_valid_address_submission.py",
7+
"test_demo_ad_name_org_captured_in_doorhanger_and_stored.py",
78
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py"
89
]
910
}

l10n_CM/region/US.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"test_demo_cc_doorhanger_shown_on_valid_credit_card_submission.py",
55
"test_demo_cc_add_new_credit_card.py",
66
"test_demo_ad_doorhanger_shown_on_valid_address_submission.py",
7+
"test_demo_ad_name_org_captured_in_doorhanger_and_stored.py",
78
"test_demo_ad_address_data_captured_in_doorhanger_and_stored.py"
89
]
910
}

modules/browser_object_navigation.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ class Navigation(BasePage):
2222
"History": "^",
2323
"Actions": ">",
2424
}
25+
VALID_SEARCH_MODES = {
26+
"Google",
27+
"eBay",
28+
"Amazon.com",
29+
"Bing",
30+
"DuckDuckGo",
31+
"Wikipedia (en)",
32+
}
2533

2634
def expect_in_content(self, condition) -> BasePage:
2735
"""Like BasePage.expect, but guarantee we're looking at CONTEXT_CONTENT"""
@@ -171,6 +179,36 @@ def click_in_awesome_bar(self) -> BasePage:
171179
self.awesome_bar.click()
172180
return self
173181

182+
def click_search_mode_switcher(self) -> BasePage:
183+
"""
184+
click search mode switcher
185+
"""
186+
with self.driver.context(self.driver.CONTEXT_CHROME):
187+
self.search_mode_switcher = self.get_element("searchmode-switcher")
188+
self.search_mode_switcher.click()
189+
return self
190+
191+
def set_search_mode(self, search_mode: str) -> BasePage:
192+
"""
193+
set new search location if search_mode in VALID_SEARCH_MODES
194+
195+
Parameter:
196+
search_mode (str): search mode to be selected
197+
198+
Raises:
199+
StopIteration: if a valid search mode is not found in the list of valid elements.
200+
"""
201+
# check if search_mode is valid, otherwise raise error.
202+
if search_mode not in self.VALID_SEARCH_MODES:
203+
raise ValueError("search location is not valid.")
204+
# switch to chrome context
205+
with self.driver.context(self.driver.CONTEXT_CHROME):
206+
# get list of all valid search modes and filter by label
207+
self.get_element(
208+
"search-mode-switcher-option", labels=[search_mode]
209+
).click()
210+
return self
211+
174212
def context_click_in_awesome_bar(self) -> BasePage:
175213
self.set_awesome_bar()
176214
actions = ActionChains(self.driver)

modules/data/autofill_popup.components.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@
8585
"groups": []
8686
},
8787

88+
"address-doorhanger-name": {
89+
"selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:first-of-type span",
90+
"strategy": "css",
91+
"groups": []
92+
},
93+
94+
"address-doorhanger-org": {
95+
"selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(2) span",
96+
"strategy": "css",
97+
"groups": []
98+
},
99+
88100
"address-doorhanger-street": {
89101
"selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(3) span",
90102
"strategy": "css",

modules/data/navigation.components.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@
322322
"strategy": "id",
323323
"groups": []
324324
},
325-
326325
"bookmarks-type-dropdown": {
327326
"selectorData": "editBMPanel_folderMenuList",
328327
"strategy": "id",
@@ -569,7 +568,6 @@
569568
"searchmode-switcher-settings": {
570569
"selectorData": "searchmode-switcher-popup-search-settings-button",
571570
"strategy": "id",
572-
573571
"groups": []
574572
},
575573

modules/page_object_prefs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,12 @@ 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)
402403
self.click_on(option_id)
403404
self.element_attribute_contains(option_id, "checked", "")
404405
return self

0 commit comments

Comments
 (0)