Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions modules/browser_object_autofill_popup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from typing import Union

from selenium.webdriver.remote.webelement import WebElement
Expand Down Expand Up @@ -126,3 +127,19 @@ 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
time.sleep(1)
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
)
22 changes: 22 additions & 0 deletions modules/page_object_autofill.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading