diff --git a/l10n_CM/Unified/test_demo_ad_4a_highlight_name_org_fields.py b/l10n_CM/Unified/test_demo_ad_4a_highlight_name_org_fields.py index f33754cbf..c415fbe9a 100644 --- a/l10n_CM/Unified/test_demo_ad_4a_highlight_name_org_fields.py +++ b/l10n_CM/Unified/test_demo_ad_4a_highlight_name_org_fields.py @@ -38,7 +38,7 @@ def test_address_yellow_highlight_on_name_organization_fields( autofill_popup.ensure_autofill_dropdown_visible() # Click on the first element from the autocomplete dropdown - autofill_popup.select_nth_element(1) + autofill_popup.select_autofill_panel() field_to_test = ["given_name", "family_name", "name", "organization"] # Verify the name and organization fields are highlighted diff --git a/l10n_CM/Unified/test_demo_ad_4b_highlight_address_fields.py b/l10n_CM/Unified/test_demo_ad_4b_highlight_address_fields.py index 69b70f9c2..f96363791 100644 --- a/l10n_CM/Unified/test_demo_ad_4b_highlight_address_fields.py +++ b/l10n_CM/Unified/test_demo_ad_4b_highlight_address_fields.py @@ -33,7 +33,7 @@ def test_address_yellow_highlight_address_fields( autofill_popup.ensure_autofill_dropdown_visible() # Click on the first element from the autocomplete dropdown - autofill_popup.select_nth_element(1) + autofill_popup.select_autofill_panel() field_to_test = [ "street_address", diff --git a/l10n_CM/Unified/test_demo_ad_4c_highlight_phone_email_fields.py b/l10n_CM/Unified/test_demo_ad_4c_highlight_phone_email_fields.py index ed1c4a271..81b498bcc 100644 --- a/l10n_CM/Unified/test_demo_ad_4c_highlight_phone_email_fields.py +++ b/l10n_CM/Unified/test_demo_ad_4c_highlight_phone_email_fields.py @@ -33,7 +33,7 @@ def test_address_yellow_highlight_address_fields( autofill_popup.ensure_autofill_dropdown_visible() # Click on the first element from the autocomplete dropdown - autofill_popup.select_nth_element(1) + autofill_popup.select_autofill_panel() field_to_test = ["email", "telephone"] # Verify the address fields are highlighted diff --git a/modules/browser_object_autofill_popup.py b/modules/browser_object_autofill_popup.py index d1c59ac4f..88bd6ac89 100644 --- a/modules/browser_object_autofill_popup.py +++ b/modules/browser_object_autofill_popup.py @@ -26,29 +26,32 @@ def verify_element_displayed(self, reference: Union[str, tuple, WebElement]): @BasePage.context_chrome def ensure_autofill_dropdown_not_visible(self): """ - Verifies that the autofill dropdown does NOT appear - checks if the parent pop up component have children elements before explicit wait. + Verifies that the autofill dropdown does not appear + checks if the parent pop up component has hidden attribute. """ self.element_exists("pop-up-component") popup_component = self.get_element("pop-up-component") - if popup_component and len(popup_component.get_attribute("innerHTML")) > 1: - self.element_not_visible("select-form-option") + if len(popup_component.get_attribute("innerHTML")) > 1: + self.expect_element_attribute_contains( + "pop-up-component-box", "style", "0px;" + ) + else: + self.expect_element_attribute_contains("pop-up-component", "hidden", "true") return self @BasePage.context_chrome - def ensure_autofill_dropdown_visible(self, field_element: WebElement = None): + def ensure_autofill_dropdown_visible(self): """ Verifies that the autofill dropdown appears - checks if the parent pop up component have children elements before explicit wait. - - Arguments: - field_element: if field element is given. - check whether it is a select element. pass the check if it is. + checks if the parent pop up component has hidden attribute. """ - self.element_exists("pop-up-component") - popup_component = self.get_element("pop-up-component") - if popup_component: - self.element_visible("select-form-option") + self.element_clickable("pop-up-component-box") + return self + + @BasePage.context_chrome + def hover_over_autofill_panel(self): + self.element_visible("select-form-option") + self.hover("select-form-option") return self # Interaction with popup elements @@ -103,12 +106,17 @@ def select_nth_element(self, index: int): Arguments: index (int): The index of the element to retrieve (1-based) """ - self.wait.until( - EC.element_to_be_clickable( - self.get_element("select-form-option-by-index", labels=[str(index)]) - ) - ) - self.get_element("select-form-option-by-index", labels=[str(index)]).click() + self.element_clickable("select-form-option-by-index", labels=[str(index)]) + self.click_on("select-form-option-by-index", labels=[str(index)]) + + @BasePage.context_chrome + def select_autofill_panel(self): + """ + Select the first autofill panel in the autocomplete list. + """ + self.element_clickable("select-form-option-autofill") + self.click_on("select-form-option-autofill") + return self @BasePage.context_chrome def get_primary_value(self, element: WebElement) -> str: diff --git a/modules/data/autofill_popup.components.json b/modules/data/autofill_popup.components.json index c87293313..be666298f 100644 --- a/modules/data/autofill_popup.components.json +++ b/modules/data/autofill_popup.components.json @@ -1,167 +1,158 @@ { - "context": "chrome", - "do-not-cache": true, - "autofill-panel": { - "selectorData": "PopupAutoComplete", - "strategy": "id", - "groups": [] - }, - - "doorhanger-save-button": { - "selectorData": "button[label^='Save'].popup-notification-primary-button", - "strategy": "css", - "groups": [] - }, - - "doorhanger-dropdown-button": { - "selectorData": "button[aria-label='More actions']", - "strategy": "css", - "groups": [] - }, - - "doorhanger-dropdown-never-save-cards-button": { - "selectorData": "menuitem[label='Never save cards']", - "strategy": "css", - "groups": [] - }, - - "doorhanger-more-actions-button": { - "selectorData": "[data-l10n-id='popup-notification-more-actions-button']", - "strategy": "css", - "groups": [] - }, - - "doorhanger-never-save-login-button": { - "selectorData": "menuitem[label='Never save']", - "strategy": "css", - "groups": [] - }, - - "doorhanger-update-button": { - "selectorData": "button[label^='Update']", - "strategy": "css", - "groups": [] - }, - - "pop-up-component": { - "selectorData": "PopupAutoComplete", - "strategy": "id", - "groups": [] - }, - - "select-form-option": { - "selectorData": ".autocomplete-richlistbox .autocomplete-richlistitem", - "strategy":"css", - "groups": [] - }, - - "select-form-option-by-value": { - "selectorData": ".autocomplete-richlistbox .autocomplete-richlistitem[ac-value='{value}']", - "strategy":"css", - "groups": [] - }, - - "clear-form-option": { - "selectorData": ".autocomplete-richlistbox .autocomplete-richlistitem[ac-value='Clear Autofill Form']", - "strategy":"css", - "groups": [] - }, - - "select-form-option-by-index": { - "selectorData": ".autocomplete-richlistbox .autocomplete-richlistitem:nth-child({index})", - "strategy":"css", - "groups": [ - "doNotCache" - ] - }, - - "update-card-info-popup-button": { - "selectorData": "button[label='Update existing card']", - "strategy": "css", - "groups": [] - }, - - "cc-saved-options": { - "selectorData": "option[data-l10n-id='credit-card-label-number-name-expiration-2']", - "strategy": "css", - "groups": [] - }, - - "password-update-doorhanger": { - "selectorData": "//*[contains(@class, 'popup-notification-description') and @popupid='password']", - "strategy": "xpath", - "groups": [] - }, - - "address-save-doorhanger": { - "selectorData": "address-save-update-notification-content", - "strategy": "class", - "groups": [] - }, - - "cc-doorhanger-data": { - "selectorData": "popupnotificationcontent[class='credit-card-save-update-notification-content'] description", - "strategy": "css", - "groups": [] - }, - - "address-doorhanger-email": { - "selectorData": "div.address-save-update-row-container:nth-of-type(2) div p:first-of-type span", - "strategy": "css", - "groups": [] - }, - - "address-doorhanger-phone": { - "selectorData": "div.address-save-update-row-container:nth-of-type(2) div p:nth-of-type(2) span", - "strategy": "css", - "groups": [] - }, - - "address-doorhanger-name": { - "selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:first-of-type span", - "strategy": "css", - "groups": [] - }, - - "address-doorhanger-org": { - "selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(2) span", - "strategy": "css", - "groups": [] - }, - - "address-doorhanger-street": { - "selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(3) span", - "strategy": "css", - "groups": [] - }, - - "address-doorhanger-city": { - "selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-of-type(1)", - "strategy": "css", - "groups": [] - }, - - "address-doorhanger-state": { - "selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-of-type(3)", - "strategy": "css", - "groups": [] - }, - - "address-doorhanger-zip": { - "selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-last-of-type(1)", - "strategy": "css", - "groups": [] - }, - - "address-doorhanger-country": { - "selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(5) span", - "strategy": "css", - "groups": [] - }, + "context": "chrome", + "do-not-cache": true, + "autofill-panel": { + "selectorData": "PopupAutoComplete", + "strategy": "id", + "groups": [] + }, + "doorhanger-save-button": { + "selectorData": "button[label^='Save'].popup-notification-primary-button", + "strategy": "css", + "groups": [] + }, + "doorhanger-dropdown-button": { + "selectorData": "button[aria-label='More actions']", + "strategy": "css", + "groups": [] + }, + "doorhanger-dropdown-never-save-cards-button": { + "selectorData": "menuitem[label='Never save cards']", + "strategy": "css", + "groups": [] + }, + "doorhanger-more-actions-button": { + "selectorData": "[data-l10n-id='popup-notification-more-actions-button']", + "strategy": "css", + "groups": [] + }, + "doorhanger-never-save-login-button": { + "selectorData": "menuitem[label='Never save']", + "strategy": "css", + "groups": [] + }, + "doorhanger-update-button": { + "selectorData": "button[label^='Update']", + "strategy": "css", + "groups": [] + }, + "pop-up-component": { + "selectorData": "PopupAutoComplete", + "strategy": "id", + "groups": [ + "doNotCache" + ] + }, + "pop-up-component-box": { + "selectorData": "#PopupAutoComplete richlistbox", + "strategy": "css", + "groups": [] + }, + "select-form-option": { + "selectorData": "#PopupAutoComplete .autocomplete-richlistitem", + "strategy": "css", + "groups": [ + "doNotCache" + ] + }, + "select-form-option-by-value": { + "selectorData": ".autocomplete-richlistbox .autocomplete-richlistitem[ac-value='{value}']", + "strategy": "css", + "groups": [] + }, + "clear-form-option": { + "selectorData": ".autocomplete-richlistbox .autocomplete-richlistitem[ac-value='Clear Autofill Form']", + "strategy": "css", + "groups": [] + }, + "select-form-option-autofill": { + "selectorData": ".autocomplete-richlistitem[originaltype='autofill']", + "strategy": "css", + "groups": [ + "doNotCache" + ] + }, + "select-form-option-by-index": { + "selectorData": ".autocomplete-richlistitem .autocomplete-richlistitem:nth-child({index})", + "strategy": "css", + "groups": [ + "doNotCache" + ] + }, + "update-card-info-popup-button": { + "selectorData": "button[label='Update existing card']", + "strategy": "css", + "groups": [] + }, + "cc-saved-options": { + "selectorData": "option[data-l10n-id='credit-card-label-number-name-expiration-2']", + "strategy": "css", + "groups": [] + }, + "password-update-doorhanger": { + "selectorData": "//*[contains(@class, 'popup-notification-description') and @popupid='password']", + "strategy": "xpath", + "groups": [] + }, + "address-save-doorhanger": { + "selectorData": "address-save-update-notification-content", + "strategy": "class", + "groups": [] + }, + "cc-doorhanger-data": { + "selectorData": "popupnotificationcontent[class='credit-card-save-update-notification-content'] description", + "strategy": "css", + "groups": [] + }, + "address-doorhanger-email": { + "selectorData": "div.address-save-update-row-container:nth-of-type(2) div p:first-of-type span", + "strategy": "css", + "groups": [] + }, + "address-doorhanger-phone": { + "selectorData": "div.address-save-update-row-container:nth-of-type(2) div p:nth-of-type(2) span", + "strategy": "css", + "groups": [] + }, + "address-doorhanger-name": { + "selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:first-of-type span", + "strategy": "css", + "groups": [] + }, + "address-doorhanger-org": { + "selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(2) span", + "strategy": "css", + "groups": [] + }, + "address-doorhanger-street": { + "selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(3) span", + "strategy": "css", + "groups": [] + }, + "address-doorhanger-city": { + "selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-of-type(1)", + "strategy": "css", + "groups": [] + }, + "address-doorhanger-state": { + "selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-of-type(3)", + "strategy": "css", + "groups": [] + }, + "address-doorhanger-zip": { + "selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(4) span:nth-last-of-type(1)", + "strategy": "css", + "groups": [] + }, + "address-doorhanger-country": { + "selectorData": "div.address-save-update-row-container:nth-of-type(1) div p:nth-of-type(5) span", + "strategy": "css", + "groups": [] + }, "preview-form-container": { - "selectorData": ".autocomplete-richlistbox richlistitem", - "strategy": "css", - "groups": [] - } + "selectorData": ".autocomplete-richlistbox richlistitem", + "strategy": "css", + "groups": [] + } } diff --git a/modules/page_object_autofill.py b/modules/page_object_autofill.py index 6a9c69593..013233e43 100644 --- a/modules/page_object_autofill.py +++ b/modules/page_object_autofill.py @@ -523,7 +523,7 @@ def sanitize_preview_data(self, field, value, region): value = self.util.normalize_regional_phone_numbers(value, region) return value - def select_autofill_option(self, field, index: int = 1): + def select_autofill_option(self, field): """ Presses the autofill panel that pops up after you double-click an input field @@ -537,7 +537,7 @@ def select_autofill_option(self, field, index: int = 1): autofill_field.clear() self.double_click("form-field", labels=[field]) self.autofill_popup.ensure_autofill_dropdown_visible() - self.autofill_popup.select_nth_element(index) + self.autofill_popup.select_autofill_panel() else: logging.info(f"Field: {field} is a select element. No autofill option.") return self @@ -607,7 +607,7 @@ def check_autofill_preview_for_field( autofill_field.clear() self.double_click("form-field", labels=[field]) self.autofill_popup.ensure_autofill_dropdown_visible() - self.autofill_popup.hover("select-form-option") + self.autofill_popup.hover_over_autofill_panel() self.verify_autofill_data_on_hover(sample_data, region) self.click_on("form-field", labels=[field]) else: @@ -664,7 +664,7 @@ def clear_and_verify( # Double-click a field and choose the first element from the autocomplete dropdown self.double_click("form-field", labels=[field]) self.autofill_popup.ensure_autofill_dropdown_visible() - self.autofill_popup.select_nth_element(1) + self.autofill_popup.select_autofill_panel() if sample_data: ## verify data