class RemoveFilter(MenuPageElement): _locator = staticmethod(events.appears(locators.filters.menu.remove_filter.locator)) _selected_locator = staticmethod(locators.filters.menu.remove_filter.selected_locator) _selector = staticmethod(lambda x: x.click()) button_yes = ButtonPageElement(events.appears(locators.filters.menu.remove_filter.button_yes)) button_no = ButtonPageElement(events.appears(locators.filters.menu.remove_filter.button_no))
def _select(self): """if not selected, select""" try: # already selected? self._selected_locator() except NoSuchElementException as e: # nope --- click the menu and try again self._selector(self._locator()) appears(self._selected_locator, timeout=5.0, message="selecting menu %s" % self)()
def _select(self): '''if not selected, select''' try: # already selected? self._selected_locator() except NoSuchElementException as e: # nope --- click the menu and try again self._selector(self._locator()) appears(self._selected_locator, timeout=5.0, message='selecting menu %s' % self)()
class DefaultFilterMenu(BaseFilterMenu): _locator = staticmethod(events.appears(locators.filters.default_filter_menu.locator)) _selected_locator = staticmethod(locators.filters.default_filter_menu.selected_locator) filter_name = BasePageElement(events.appears(locators.filters.default_filter_menu.filter_name)) filter_description = BasePageElement(events.appears(locators.filters.default_filter_menu.filter_description)) status_field = BasePageElement(events.appears(locators.filters.default_filter_menu.status_field)) satellite_field = BasePageElement(events.appears(locators.filters.default_filter_menu.satellite_field)) organizations_field = BasePageElement(events.appears(locators.filters.default_filter_menu.organizations_field)) lifecycle_field = BasePageElement(events.appears(locators.filters.default_filter_menu.lifecycle_field)) hours_field = BasePageElement(events.appears(locators.filters.default_filter_menu.hours_field)) start_date = BasePageElement(events.appears(locators.filters.default_filter_menu.start_date)) end_date = BasePageElement(events.appears(locators.filters.default_filter_menu.end_date))
class DateRangeMenu(MenuPageElement): _locator = staticmethod(events.appears(locators.filters.date_range_menu.locator)) _selected_locator = staticmethod(locators.filters.date_range_menu.selected_locator) _selector = staticmethod(lambda x: x.click()) start_date = InputPageElement(locators.filters.date_range_menu.start_date) end_date = InputPageElement(locators.filters.date_range_menu.end_date)
class BaseFilterMenu(MenuPageElement): '''few common things between New Filter Menu and Filter Menu''' _selector = staticmethod(lambda x: x.click()) close_link = LinkPageElement(events.appears(locators.filters.base_menu.close_link)) def close(self): self.close_link.click()
class NewFilterMenu(BaseFilterMenu): _locator = staticmethod(events.appears(locators.filters.new_filter_menu.locator)) _selected_locator = staticmethod(locators.filters.new_filter_menu.selected_locator) filter_name = InputPageElement(events.appears(locators.filters.new_filter_menu.filter_name)) filter_description = InputPageElement(events.appears(locators.filters.new_filter_menu.filter_description)) status_field = StatusField() organizations_field = OrganizationsField() hours_menu = HoursMenu() date_range_menu = DateRangeMenu() lifecycle_field = LifeCycleField() save_filter = InputPageElement(locators.filters.new_filter_menu.save_filter) validation_error_message = ValidationErrorMessage() @staticmethod def submit(): NewFilterMenu.save_filter.click()
def __init__(self, name): self._name = name #self._locator = appears(types.MethodType(lambda self: locators.users.user_menu.locator(self._name), self)) self._locator = appears( types.MethodType( lambda self: locators.users.user_menu.locator(self._name), self)) self._selected_locator = types.MethodType( lambda self: locators.users.user_menu.selected_locator(self._name), self)
class InfoReportMenu(MenuPageElement): _locator = staticmethod(events.appears(locators.report.info_menu.locator)) _selected_locator = staticmethod( locators.report.info_menu.selected_locator) _selector = staticmethod(lambda x: x.click()) filter_name = FilterNameField() filter_description = DescriptionField() subscription_status = SubscriptionField() organizations = OrganizationsField() hours = HoursField() lifecycle_state = LifecycleField()
class ValidationErrorMessage(ContainerPageElement): _locator = staticmethod(events.appears(locators.filters.new_filter_menu.validation_error_message.locator)) close_link = LinkPageElement(locators.filters.new_filter_menu.validation_error_message.close_link) message_filter_name = BasePageElement(events.appears(locators.filters.new_filter_menu.validation_error_message.message_filter_name)) message_filter_name_white_space = BasePageElement(events.appears(locators.filters.new_filter_menu.validation_error_message.message_filter_name_white_space)) message_status_field = BasePageElement(events.appears(locators.filters.new_filter_menu.validation_error_message.message_status_field)) message_lifecycle_field = BasePageElement(events.appears(locators.filters.new_filter_menu.validation_error_message.message_lifecycle_field)) message_hour_date_criteria = BasePageElement(events.appears(locators.filters.new_filter_menu.validation_error_message.message_hour_date_criteria)) message_date_criteria = BasePageElement(events.appears(locators.filters.new_filter_menu.validation_error_message.message_date_criteria)) @staticmethod def close(): ValidationErrorMessage.close_link.click()
class SubscriptionField(InfoReportField): _locator = staticmethod( appears(locators.report.info_menu.subscription_status)) _substr = "Subscription Status: "
def get_organisation(name): '''return organisation link page element''' return LinkPageElement(appears(lambda: locators.sam_page.organisation_menu.organisation_link(name)))
def __init__(self, name): self._name = name #self._locator = appears(types.MethodType(lambda self: locators.users.user_menu.locator(self._name), self)) self._locator = appears(types.MethodType(lambda self: locators.users.user_menu.locator(self._name), self)) self._selected_locator = types.MethodType(lambda self: locators.users.user_menu.selected_locator(self._name), self)
class InvalidSubscriptions(ContainerPageElement): _locator = staticmethod( appears(locators.report.invalid_subscriptions.locator)) count = BasePageElement(locators.report.invalid_subscriptions.count)
class CurrentSubscriptions(ContainerPageElement): _locator = staticmethod( appears(locators.report.current_subscriptions.locator)) count = BasePageElement(locators.report.current_subscriptions.count)
class FilterNameField(InfoReportField): _locator = staticmethod(appears(locators.report.info_menu.filter_name)) _substr = "Filter: "
class FilterMenu(BaseFilterMenu): '''a Filter meant to be selected on a page''' filter_name = BasePageElement(events.appears(locators.filters.menu.filter_name)) filter_description = BasePageElement(events.appears(locators.filters.menu.filter_description)) hours_field = BasePageElement(events.appears(locators.filters.menu.hours_field)) status_field = BasePageElement(events.appears(locators.filters.menu.status_field)) organizations_field = BasePageElement(events.appears(locators.filters.menu.organizations_field)) lifecycle_field = BasePageElement(events.appears(locators.filters.menu.lifecycle_field)) start_date = BasePageElement(events.appears(locators.filters.menu.start_date)) end_date = BasePageElement(events.appears(locators.filters.menu.end_date)) run_button = ButtonPageElement(events.appears(locators.filters.menu.run_button)) remove_filter = RemoveFilter() remove_default_filter = BasePageElement(locators.filters.menu.remove_default_filter) encrypt_export = InputPageElement(events.appears(locators.filters.menu.encrypt_export)) skip_json_export = InputPageElement(events.appears(locators.filters.menu.skip_json_export)) def __init__(self, name): self._name = name # instance-level locator; monkeypatching for each filter self._locator = events.appears(types.MethodType(lambda self: locators.filters.menu.locator(self._name), self)) self._selected_locator = types.MethodType(lambda self: locators.filters.menu.selected_locator(self._name), self) def run_report(self): '''click the run button and return appropriate ReportPageObject instance''' FilterMenu.run_button.click() return report.ReportPageObject(filter_name=self._name) def export_report(self): pass @staticmethod def remove(): FilterMenu.remove_filter.button_yes.click()
class DescriptionField(InfoReportField): _locator = staticmethod( appears(locators.report.info_menu.filter_description)) _substr = "Description: "
def __init__(self, name): self._name = name # instance-level locator; monkeypatching for each filter self._locator = events.appears(types.MethodType(lambda self: locators.filters.menu.locator(self._name), self)) self._selected_locator = types.MethodType(lambda self: locators.filters.menu.selected_locator(self._name), self)
class OrganizationsField(InfoReportField): _locator = staticmethod(appears(locators.report.info_menu.organizations)) _substr = "Organizations: "
class HoursMenu(MenuPageElement): _locator = staticmethod(events.appears(locators.filters.hours_menu.locator)) _selected_locator = staticmethod(locators.filters.hours_menu.selected_locator) _selector = staticmethod(lambda x: x.click()) hours_field = HoursField()
class HoursField(InfoReportField): _locator = staticmethod(appears(locators.report.info_menu.hours)) _substr = "Hours: "
class LifecycleField(InfoReportField): _locator = staticmethod(appears(locators.report.info_menu.lifecycle_state)) _substr = "LifeCycle State: "