From ee308cda53e1cfe56d3e139b15f3bdf88ae57be7 Mon Sep 17 00:00:00 2001 From: Hani Yacoub Date: Fri, 7 Nov 2025 13:43:00 +0200 Subject: [PATCH 1/4] Stabilize test auto_saved_generated_password_context_menu --- modules/browser_object_autofill_popup.py | 15 ++++++++++++ modules/page_object_autofill.py | 22 +++++++++++++++++ ...o_saved_generated_password_context_menu.py | 24 +++---------------- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/modules/browser_object_autofill_popup.py b/modules/browser_object_autofill_popup.py index b9350d717..4b46ca97c 100644 --- a/modules/browser_object_autofill_popup.py +++ b/modules/browser_object_autofill_popup.py @@ -126,3 +126,18 @@ def get_primary_value(self, element: WebElement) -> str: Returns: str: The primary value extracted from the element's attribute """ return element.get_attribute("ac-value") + + @BasePage.context_chrome + def verify_update_password_doorhanger(self, nav, expected_text): + """ + Wait for and verify that the 'Update password' doorhanger is displayed + with the expected text + """ + # Wait for and open the doorhanger + nav.expect(lambda _: nav.element_visible("password-notification-key")) + nav.click_on("password-notification-key") + + # Verify the doorhanger text + self.expect( + lambda _: expected_text in self.get_element("password-update-doorhanger").text + ) diff --git a/modules/page_object_autofill.py b/modules/page_object_autofill.py index bb198ac54..3c0b88f37 100644 --- a/modules/page_object_autofill.py +++ b/modules/page_object_autofill.py @@ -843,6 +843,28 @@ def verify_field_empty(self, field: str): self.parent.wait.until(lambda _: element.get_attribute("value") == "") return element + def generate_secure_password(self, context_menu): + """ + Opens the login autofill page, triggers the 'Suggest Strong Password' + option from the context menu, confirms the generated password, + and waits until the field is filled. + """ + self.parent.open() + self.parent.context_click("password-login-field") + context_menu.click_and_hide_menu("context-menu-suggest-strong-password") + + # Switch to chrome context to click 'Use a Securely Generated Password' + with self.parent.driver.context(self.parent.driver.CONTEXT_CHROME): + self.parent.get_element("generated-securely-password").click() + + # Wait until the password field is actually filled + self.parent.expect( + lambda _: ( + (elem := self.parent.get_element("password-login-field")) + and elem.get_attribute("value") not in ("", None) + ) + ) + class TextAreaFormAutofill(Autofill): """ diff --git a/tests/password_manager/test_auto_saved_generated_password_context_menu.py b/tests/password_manager/test_auto_saved_generated_password_context_menu.py index 6649a0dcd..78bfecdc8 100644 --- a/tests/password_manager/test_auto_saved_generated_password_context_menu.py +++ b/tests/password_manager/test_auto_saved_generated_password_context_menu.py @@ -19,7 +19,6 @@ def add_to_prefs_list(): return [("signon.rememberSignons", True)] -@pytest.mark.unstable(reason="Bug 1996838") def test_auto_saved_generated_password_context_menu(driver: Firefox): """ C2248176 - Securely Generated Password is auto-saved when generated from password field context menu @@ -34,28 +33,11 @@ def test_auto_saved_generated_password_context_menu(driver: Firefox): autofill_popup_panel = AutofillPopup(driver) # Open login autofill test page and select "Suggest Strong Password..." from password field context menu - login_autofill.open() - login_autofill.context_click("password-login-field") - context_menu.click_and_hide_menu("context-menu-suggest-strong-password") - - # Select "Use a Securely Generated Password" in password field and check the "Update password" doorhanger - with driver.context(driver.CONTEXT_CHROME): - login_autofill.get_element("generated-securely-password").click() - - # Wait for password field to actually get filled - login_autofill.expect( - lambda _: login_autofill.get_element("password-login-field").get_attribute( - "value" - ) - != "" - ) + login_autofill.LoginForm(login_autofill).generate_secure_password(context_menu) # Verify the update doorhanger is displayed - nav.expect(lambda _: nav.element_visible("password-notification-key")) - nav.click_on("password-notification-key") - autofill_popup_panel.expect( - lambda _: UPDATE_DOORHANGER_TEXT - in autofill_popup_panel.get_element("password-update-doorhanger").text + autofill_popup_panel.verify_update_password_doorhanger( + nav, UPDATE_DOORHANGER_TEXT ) # Navigate to about:logins page From 88df55941a19514346bc4bd51fc4e602cd9b2fb8 Mon Sep 17 00:00:00 2001 From: Hani Yacoub Date: Mon, 10 Nov 2025 16:07:00 +0200 Subject: [PATCH 2/4] add lower --- modules/browser_object_autofill_popup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/browser_object_autofill_popup.py b/modules/browser_object_autofill_popup.py index 4b46ca97c..d419403eb 100644 --- a/modules/browser_object_autofill_popup.py +++ b/modules/browser_object_autofill_popup.py @@ -139,5 +139,5 @@ def verify_update_password_doorhanger(self, nav, expected_text): # Verify the doorhanger text self.expect( - lambda _: expected_text in self.get_element("password-update-doorhanger").text + lambda _: expected_text in self.get_element("password-update-doorhanger").text.lower() ) From dcfcff2683ae40e908f0819e6ba478a43b3510cc Mon Sep 17 00:00:00 2001 From: Hani Yacoub Date: Mon, 10 Nov 2025 16:14:02 +0200 Subject: [PATCH 3/4] remove lower --- modules/browser_object_autofill_popup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/browser_object_autofill_popup.py b/modules/browser_object_autofill_popup.py index d419403eb..4b46ca97c 100644 --- a/modules/browser_object_autofill_popup.py +++ b/modules/browser_object_autofill_popup.py @@ -139,5 +139,5 @@ def verify_update_password_doorhanger(self, nav, expected_text): # Verify the doorhanger text self.expect( - lambda _: expected_text in self.get_element("password-update-doorhanger").text.lower() + lambda _: expected_text in self.get_element("password-update-doorhanger").text ) From 10fc296eea5689c3d969545bcacf4bbc8b4ee788 Mon Sep 17 00:00:00 2001 From: Hani Yacoub Date: Wed, 12 Nov 2025 16:10:55 +0200 Subject: [PATCH 4/4] add sleep --- modules/browser_object_autofill_popup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/browser_object_autofill_popup.py b/modules/browser_object_autofill_popup.py index 4b46ca97c..b0bbe5380 100644 --- a/modules/browser_object_autofill_popup.py +++ b/modules/browser_object_autofill_popup.py @@ -1,3 +1,4 @@ +import time from typing import Union from selenium.webdriver.remote.webelement import WebElement @@ -134,6 +135,7 @@ def verify_update_password_doorhanger(self, nav, expected_text): with the expected text """ # Wait for and open the doorhanger + time.sleep(1) nav.expect(lambda _: nav.element_visible("password-notification-key")) nav.click_on("password-notification-key")