Skip to content

Commit

Permalink
Implemented the AddOnInstallFailed, AddOnProgress, and AddOnInstallRe…
Browse files Browse the repository at this point in the history
…start classes
  • Loading branch information
Temidayo32 committed Oct 23, 2024
1 parent 63298bf commit 7055a30
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions foxpuppet/windows/browser/notifications/addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,56 @@ def close(self):
class AddOnInstallRestart(BaseNotification):
"""Add-on install restart notification."""

def restart_now(self):
"""Restart Firefox immediately to complete the add-on installation."""
with self.selenium.context(self.selenium.CONTEXT_CHROME):
self.find_primary_button().click()

def restart_later(self):
"""Defer Firefox restart for later."""
with self.selenium.context(self.selenium.CONTEXT_CHROME):
self.find_secondary_button().click()


class AddOnInstallFailed(BaseNotification):
"""Add-on install failed notification."""

@property
def error_message(self):
"""Provide access to the error message.
Returns:
str: The error message explaining why the installation failed.
"""
with self.selenium.context(self.selenium.CONTEXT_CHROME):
return self.find_description().text

def close(self):
"""Close the failed installation notification."""
with self.selenium.context(self.selenium.CONTEXT_CHROME):
self.find_primary_button().click()


class AddOnProgress(BaseNotification):
"""Add-on progress notification."""

@property
def is_downloading(self):
"""Check if the add-on is currently downloading.
Returns:
bool: True if the download and verification is in progress.
"""
with self.selenium.context(self.selenium.CONTEXT_CHROME):
return "Downloading and verifying add-on…" in self.find_description().text

def wait_until_complete(self, timeout=None):
"""Wait until the progress notification disappears, indicating completion.
Args:
timeout (int, optional): Maximum time to wait in seconds.
"""
self.window.wait_for_notification(None, timeout=timeout)


# Clean up of these notifications will happen once Firefox ESR is past version 63
Expand Down

0 comments on commit 7055a30

Please sign in to comment.