Skip to content

Commit f6c020b

Browse files
Merge pull request #727 from mozilla/philimon/rework_ensure_visible
Philimon/rework ensure visible
2 parents 6628ef4 + 3825e47 commit f6c020b

6 files changed

+189
-190
lines changed

l10n_CM/Unified/test_demo_ad_4a_highlight_name_org_fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_address_yellow_highlight_on_name_organization_fields(
3838
autofill_popup.ensure_autofill_dropdown_visible()
3939

4040
# Click on the first element from the autocomplete dropdown
41-
autofill_popup.select_nth_element(1)
41+
autofill_popup.select_autofill_panel()
4242

4343
field_to_test = ["given_name", "family_name", "name", "organization"]
4444
# Verify the name and organization fields are highlighted

l10n_CM/Unified/test_demo_ad_4b_highlight_address_fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_address_yellow_highlight_address_fields(
3333
autofill_popup.ensure_autofill_dropdown_visible()
3434

3535
# Click on the first element from the autocomplete dropdown
36-
autofill_popup.select_nth_element(1)
36+
autofill_popup.select_autofill_panel()
3737

3838
field_to_test = [
3939
"street_address",

l10n_CM/Unified/test_demo_ad_4c_highlight_phone_email_fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_address_yellow_highlight_address_fields(
3333
autofill_popup.ensure_autofill_dropdown_visible()
3434

3535
# Click on the first element from the autocomplete dropdown
36-
autofill_popup.select_nth_element(1)
36+
autofill_popup.select_autofill_panel()
3737

3838
field_to_test = ["email", "telephone"]
3939
# Verify the address fields are highlighted

modules/browser_object_autofill_popup.py

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,32 @@ def verify_element_displayed(self, reference: Union[str, tuple, WebElement]):
2626
@BasePage.context_chrome
2727
def ensure_autofill_dropdown_not_visible(self):
2828
"""
29-
Verifies that the autofill dropdown does NOT appear
30-
checks if the parent pop up component have children elements before explicit wait.
29+
Verifies that the autofill dropdown does not appear
30+
checks if the parent pop up component has hidden attribute.
3131
"""
3232
self.element_exists("pop-up-component")
3333
popup_component = self.get_element("pop-up-component")
34-
if popup_component and len(popup_component.get_attribute("innerHTML")) > 1:
35-
self.element_not_visible("select-form-option")
34+
if len(popup_component.get_attribute("innerHTML")) > 1:
35+
self.expect_element_attribute_contains(
36+
"pop-up-component-box", "style", "0px;"
37+
)
38+
else:
39+
self.expect_element_attribute_contains("pop-up-component", "hidden", "true")
3640
return self
3741

3842
@BasePage.context_chrome
39-
def ensure_autofill_dropdown_visible(self, field_element: WebElement = None):
43+
def ensure_autofill_dropdown_visible(self):
4044
"""
4145
Verifies that the autofill dropdown appears
42-
checks if the parent pop up component have children elements before explicit wait.
43-
44-
Arguments:
45-
field_element: if field element is given.
46-
check whether it is a select element. pass the check if it is.
46+
checks if the parent pop up component has hidden attribute.
4747
"""
48-
self.element_exists("pop-up-component")
49-
popup_component = self.get_element("pop-up-component")
50-
if popup_component:
51-
self.element_visible("select-form-option")
48+
self.element_clickable("pop-up-component-box")
49+
return self
50+
51+
@BasePage.context_chrome
52+
def hover_over_autofill_panel(self):
53+
self.element_visible("select-form-option")
54+
self.hover("select-form-option")
5255
return self
5356

5457
# Interaction with popup elements
@@ -103,12 +106,17 @@ def select_nth_element(self, index: int):
103106
Arguments:
104107
index (int): The index of the element to retrieve (1-based)
105108
"""
106-
self.wait.until(
107-
EC.element_to_be_clickable(
108-
self.get_element("select-form-option-by-index", labels=[str(index)])
109-
)
110-
)
111-
self.get_element("select-form-option-by-index", labels=[str(index)]).click()
109+
self.element_clickable("pop-up-component-box")
110+
self.click_on("select-form-option-by-index", labels=[str(index)])
111+
112+
@BasePage.context_chrome
113+
def select_autofill_panel(self):
114+
"""
115+
Select the first autofill panel in the autocomplete list.
116+
"""
117+
self.element_clickable("select-form-option-autofill")
118+
self.click_on("select-form-option-autofill")
119+
return self
112120

113121
@BasePage.context_chrome
114122
def get_primary_value(self, element: WebElement) -> str:

0 commit comments

Comments
 (0)