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 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)
示例#3
0
class LoginPageObject(RedirectingPageObject):
    _sub_url = pages.login.url

    username = InputPageElement(locators.login.username)
    password = InputPageElement(locators.login.password)
    default_org_link = LinkPageElement(events.appears(locators.login.default_org_link))
    submit_button = ButtonPageElement(locators.login.submit)

    def _assertUrl(self):
        # overriding to handle signo--non-signo redirects
        if not pages.login.check_url in SE.current_url and not pages.login.signo.url in SE.current_url:
            raise AssertionError("page %s not loaded" % self.__class__.__name__)    

    def submit(self):
        if pages.login.signo.url in SE.current_url:
            # using signo
            self.submit_button.click()
        else:
            self.submit_button.click()
            # non-signo: selecting the default org required
            # it also kinda asserts log-in succeeded
            if not pages.dashboard.url in SE.current_url:
                # some orgs are there to select?
                self.default_org_link.click()
        # assumes successful log-in by the dashboard page navigation
        assert_in(pages.dashboard.url, SE.current_url)
class HoursField(SelectPageElement):
    _locator = staticmethod(locators.filters.hours_menu.hours_field.locator)

    option_blank = InputPageElement(locators.filters.hours_menu.hours_field.option_blank)
    option_4 = InputPageElement(locators.filters.hours_menu.hours_field.option_4)
    option_8 = InputPageElement(locators.filters.hours_menu.hours_field.option_8)
    option_24 = InputPageElement(locators.filters.hours_menu.hours_field.option_24)
    option_48 = InputPageElement(locators.filters.hours_menu.hours_field.option_48)
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()
示例#6
0
class UserMenu(MenuPageElement):
    _selector = staticmethod(lambda x: x.click())
    experimental_ui = InputPageElement(
        locators.users.user_menu.experimental_ui)

    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 LifeCycleField(SelectPageElement):
    _locator = staticmethod(locators.filters.new_filter_menu.lifecycle_field.locator)

    option_active = InputPageElement(locators.filters.new_filter_menu.lifecycle_field.option_active)
    option_inactive = InputPageElement(locators.filters.new_filter_menu.lifecycle_field.option_inactive)
    option_deleted = InputPageElement(locators.filters.new_filter_menu.lifecycle_field.option_deleted)
class StatusField(SelectPageElement):
    _locator = staticmethod(locators.filters.new_filter_menu.status_field.locator)
    option_current = InputPageElement(locators.filters.new_filter_menu.status_field.option_current)
    option_invalid = InputPageElement(locators.filters.new_filter_menu.status_field.option_invalid)
    option_insufficient = InputPageElement(locators.filters.new_filter_menu.status_field.option_insufficient)