Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Commit

Permalink
Add support for new notification selectors (#243)
Browse files Browse the repository at this point in the history
* Add support for new notification selectors

* add missing docstring

* make flake8 happier
  • Loading branch information
willdurand authored and jrbenny35 committed Feb 11, 2019
1 parent ce7168a commit e8e20e8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
16 changes: 5 additions & 11 deletions foxpuppet/windows/browser/notifications/addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AddOnInstallBlocked(BaseNotification):
def allow(self):
"""Allow the add-on to be installed."""
with self.selenium.context(self.selenium.CONTEXT_CHROME):
self.root.find_anonymous_element_by_attribute("anonid", "button").click()
self.find_primary_button().click()


class AddOnInstallConfirmation(BaseNotification):
Expand All @@ -29,22 +29,18 @@ def addon_name(self):
"""
with self.selenium.context(self.selenium.CONTEXT_CHROME):
el = self.root.find_anonymous_element_by_attribute(
"class", "popup-notification-description"
)
el = self.find_description()
return el.find_element(By.CSS_SELECTOR, "b").text

def cancel(self):
"""Cancel add-on install."""
with self.selenium.context(self.selenium.CONTEXT_CHROME):
self.root.find_anonymous_element_by_attribute(
"anonid", "secondarybutton"
).click()
self.find_secondary_button().click()

def install(self):
"""Confirm add-on install."""
with self.selenium.context(self.selenium.CONTEXT_CHROME):
self.root.find_anonymous_element_by_attribute("anonid", "button").click()
self.find_primary_button().click()


class AddOnInstallComplete(BaseNotification):
Expand All @@ -54,9 +50,7 @@ def close(self):
"""Close the notification."""
with self.selenium.context(self.selenium.CONTEXT_CHROME):
if self.window.firefox_version > 63:
self.root.find_anonymous_element_by_attribute(
"anonid", "button"
).click()
self.find_primary_button().click()
self.window.wait_for_notification(None)
else:
BaseNotification.close(self)
Expand Down
38 changes: 35 additions & 3 deletions foxpuppet/windows/browser/notifications/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from abc import ABCMeta

from selenium.webdriver.common.by import By

from foxpuppet.region import Region


Expand Down Expand Up @@ -58,10 +60,40 @@ def origin(self):
with self.selenium.context(self.selenium.CONTEXT_CHROME):
return self.root.get_attribute("origin")

def find_primary_button(self):
"""Retrieve the primary button."""
if self.window.firefox_version >= 67:
return self.root.find_element(
By.CLASS_NAME, "popup-notification-primary-button")
return self.root.find_anonymous_element_by_attribute(
"anonid", "button")

def find_secondary_button(self):
"""Retrieve the secondary button."""
if self.window.firefox_version >= 67:
return self.root.find_element(
By.CLASS_NAME, "popup-notification-secondary-button")
return self.root.find_anonymous_element_by_attribute(
"anonid", "secondarybutton")

def find_description(self):
"""Retrieve the notification description."""
if self.window.firefox_version >= 67:
return self.root.find_element(
By.CLASS_NAME, "popup-notification-description")
return self.root.find_anonymous_element_by_attribute(
"class", "popup-notification-description")

def find_close_button(self):
"""Retrieve the close button."""
if self.window.firefox_version >= 67:
return self.root.find_element(
By.CLASS_NAME, "popup-notification-closebutton")
return self.root.find_anonymous_element_by_attribute(
"anonid", "closebutton")

def close(self):
"""Close the notification."""
with self.selenium.context(self.selenium.CONTEXT_CHROME):
self.root.find_anonymous_element_by_attribute(
"anonid", "closebutton"
).click()
self.find_close_button().click()
self.window.wait_for_notification(None)

0 comments on commit e8e20e8

Please sign in to comment.