def __init__(self, parent, group_title, item_name, text_filter=None, logger=None):
     Widget.__init__(self, parent, logger=logger)
     self.group_title = group_title
     self.item_name = item_name
     if text_filter is not None and not callable(text_filter):
         raise TypeError('text_filter= must be a callable')
     self.text_filter = text_filter
Пример #2
0
        class nested1(View):
            w = Widget()
            x = Widget()

            class nested2(View):
                class nested3(View):
                    w = Widget()
Пример #3
0
 def __init__(self, parent, locator=None, logger=None):
     Widget.__init__(self, parent, logger=logger)
     if locator:
         self.locator = locator
     else:
         self.locator = self.ROOT
     wait_displayed(self)
Пример #4
0
 def __init__(self, parent, logger=None):
     Widget.__init__(self, parent, logger=logger)
     self.username = TextInput(parent=self, locator=self.USERNAME)
     self.password = TextInput(parent=self, locator=self.PASSWORD)
     self.submit = Button(parent=self.parent,
                          locator=self.SUBMIT,
                          logger=logger)
Пример #5
0
    def __init__(self, parent, *text, **kwargs):
        logger = kwargs.pop("logger", None)
        Widget.__init__(self, parent, logger=logger)
        self.args = text
        self.kwargs = kwargs
        self.classes = kwargs.pop("classes", [])
        if text:
            if kwargs:  # classes should have been the only kwarg combined with text args
                raise TypeError("If you pass button text then only pass classes in addition")
            if len(text) == 1:
                self.locator_conditions = "normalize-space(.)={}".format(quote(text[0]))
            elif len(text) == 2 and text[0].lower() == "contains":
                self.locator_conditions = "contains(normalize-space(.), {})".format(quote(text[1]))
            else:
                raise TypeError("An illegal combination of text params")
        else:
            # Join the kwargs, if any
            self.locator_conditions = " and ".join(
                "@{}={}".format(attr, quote(value)) for attr, value in kwargs.items())

        if self.classes:
            if self.locator_conditions:
                self.locator_conditions += " and "
            self.locator_conditions += " and ".join(
                "contains(@class, {})".format(quote(klass))
                for klass in self.classes)
        if self.locator_conditions:
            self.locator_conditions = "and ({})".format(self.locator_conditions)
Пример #6
0
 def __init__(self, parent, *text, **kwargs):
     logger = kwargs.pop('logger', None)
     Widget.__init__(self, parent, logger=logger)
     self.args = text
     self.kwargs = kwargs
     if text:
         if kwargs and 'classes' not in kwargs:
             raise TypeError(
                 'If you pass button text then do not pass anything else.')
         if len(text) == 1:
             self.locator_conditions = 'normalize-space(.)={}'.format(
                 quote(text[0]))
         elif len(text) == 2 and text[0].lower() == 'contains':
             self.locator_conditions = 'contains(normalize-space(.), {})'.format(
                 quote(text[1]))
         else:
             raise TypeError('An illegal combination of text params')
     else:
         # Join the kwargs, if any
         self.locator_conditions = ' and '.join(
             '@{}={}'.format(attr, quote(value))
             for attr, value in kwargs.items())
     classes = kwargs.pop('classes', [])
     if classes:
         self.locator_conditions += ' and '
         self.locator_conditions += ' and '.join(
             'contains(@class, {})'.format(quote(klass))
             for klass in classes)
     if self.locator_conditions:
         self.locator_conditions = 'and ({})'.format(
             self.locator_conditions)
Пример #7
0
 def __init__(self, parent, locator=None, logger=None):
     Widget.__init__(self, parent, logger=logger)
     if locator:
         self.locator = locator
     else:
         self.locator = self.ROOT
     self._pagination = Pagination(parent=self.parent)
Пример #8
0
    class MyClass3(Widget):
        foo = MyWidget('foo')

        included1 = Widget.include(MyClass1)

        bar = MyWidget('bar')

        included2 = Widget.include(MyClass2)
Пример #9
0
 def __init__(self, parent, force_open=False, locator=None, logger=None):
     Widget.__init__(self, parent, logger=logger)
     self._force_open = force_open
     if locator:
         self.locator = locator
     else:
         self.locator = self.ROOT
     wait_displayed(self)
Пример #10
0
    class MyClass3(Widget):
        foo = MyWidget("foo")

        included1 = Widget.include(MyClass1)

        bar = MyWidget("bar")

        included2 = Widget.include(MyClass2)
Пример #11
0
 def __init__(self, parent, id=None, locator=None, logger=None):
     """Create the widget"""
     Widget.__init__(self, parent, logger=logger)
     if id:
         self.locator = self.BASE_LOCATOR.format(quote(id))
     elif locator:
         self.locator = locator
     else:
         raise TypeError("You need to specify either id or locator")
 def __init__(self, parent, id=None, locator=None, logger=None):
     """Create the widget"""
     Widget.__init__(self, parent, logger=logger)
     if id:
         self.locator = self.BASE_LOCATOR.format(quote(id))
     elif locator:
         self.locator = locator
     else:
         raise TypeError("You need to specify either id or locator")
Пример #13
0
 def __init__(self, parent, locator=None, logger=None):
     Widget.__init__(self, parent, logger=logger)
     if locator:
         self.locator = locator
     else:
         self.locator = self.ROOT
     self._filter = DropDown(parent=self,
                             locator=self.locator + self.FILTER_DROPDOWN)
     self._filter_list = FilterList(parent=self.parent)
Пример #14
0
 def __init__(self, parent, parent_entity, affected_entity, logger=None):
     Widget.__init__(self, parent, logger=logger)
     self.parent_entity = parent_entity.lower()
     self.affected_entity = affected_entity.lower()
     self.parent_locator = (
         "//div[contains(@id, 'ms-{}') and "
         "contains(@id, '{}_ids')]".format(
             self.parent_entity, self.affected_entity)
     )
Пример #15
0
 def __init__(self, parent, locator=None, logger=None):
     Widget.__init__(self, parent, logger=logger)
     if locator:
         self.locator = locator
     else:
         self.locator = self.ROOT
     self._filter_button = Button(
         parent=self.parent,
         locator=('//label[normalize-space(text())="Filters:"]/'
                  '..//*[contains(@class, "fa-filter")]'))
Пример #16
0
    class MyView(View):
        w = Widget()
        x = Widget()

        @View.nested
        class y(View):
            pass

        class z(View):
            pass
Пример #17
0
 def __init__(self, parent, *text, **kwargs):
     logger = kwargs.pop("logger", None)
     Widget.__init__(self, parent, logger=logger)
     self.args = text
     self.kwargs = kwargs
     locator = kwargs.pop("locator", None)
     if locator:
         self.locator = locator
     else:
         self.locator = self._generate_locator(*text, **kwargs)
Пример #18
0
 def __init__(self, parent, text=None, locator=None, logger=None):
     Widget.__init__(self, parent, logger=logger)
     if locator and text:
         raise ValueError("Either text or locator should be provided")
     if text:
         self.locator = self.TEXT_LOCATOR.format(quote(text))
     elif locator:
         self.locator = locator
     else:
         self.locator = self.DEFAULT_LOCATOR
Пример #19
0
 def __init__(self, parent, label=None, id=None, locator=None, logger=None):
     Widget.__init__(self, parent, logger=logger)
     label_part = " and @label={}".format(quote(label)) if label else ""
     id_part = " and @id={}".format(quote(id)) if id else ""
     if locator is not None:
         self.locator = locator
     elif label_part or id_part:
         self.locator = self.LOCATOR_START.format(label_part + id_part)
     else:
         raise TypeError(
             'You need to specify either, id, label or locator for Navigation'
         )
Пример #20
0
 def __init__(self, parent, locator=None, logger=None):
     Widget.__init__(self, parent, logger=logger)
     if locator:
         self.locator = locator
     else:
         self.locator = self.ROOT
     self._drop_down = DropDown(parent=self,
                                locator=self.locator +
                                '/*[contains(@class, "dropdown")]')
     self._sort = Sort(parent=self,
                       locator=self.locator +
                       '/button/*[contains(@class, "sort-direction")]/..')
Пример #21
0
 def __init__(self, parent, text=None, locator=None, logger=None):
     Widget.__init__(self, parent, logger=logger)
     if locator and text:
         raise ValueError("Either text or locator should be provided")
     if text:
         self.locator = ('.//div[contains(@class, "pf-c-dropdown") and '
                         "child::button[normalize-space(.)={}]]").format(
                             quote(text))
     elif locator:
         self.locator = locator
     else:
         self.locator = './/div[contains(@class, "pf-c-dropdown")][1]'
Пример #22
0
 def __init__(self, parent, logger=None):
     Widget.__init__(self, parent, logger=logger)
     self.help_menu = DropDown(
         parent=self,
         locator=self.NAVBAR_RIGHT_MENU.format('help'),
         logger=logger,
         force_open=True)
     self.user_menu = DropDown(
         parent=self,
         locator=self.NAVBAR_RIGHT_MENU.format('user'),
         logger=logger,
         force_open=True)
Пример #23
0
 def __init__(self, parent, component_id, logger=None, *args, **kwargs):
     OUIAMixin.__init__(self, klass.PF_NAME, component_id)
     if issubclass(klass, GenericLocatorWidget):
         super(klass, self).__init__(parent,
                                     self.locator,
                                     logger=logger)
     elif issubclass(klass, Table):
         super(klass, self).__init__(parent,
                                     self.locator,
                                     logger=logger,
                                     **kwargs)
     elif issubclass(klass, Dropdown):
         Widget.__init__(self, parent, logger=logger)
     else:
         super(klass, self).__init__(parent, logger=logger)
    def __init__(self, parent, label=None, id=None, locator=None, logger=None):
        Widget.__init__(self, parent, logger=logger)

        quoted_label = quote(label) if label else ""
        if label:
            label_part = " and @label={} or @aria-label={}".format(quoted_label, quoted_label)
        else:
            label_part = ""

        id_part = " and @id={}".format(quote(id)) if id else ""
        if locator is not None:
            self.locator = locator
        elif label_part or id_part:
            self.locator = self.LOCATOR_START.format(label_part + id_part)
        else:
            raise TypeError("You need to specify either, id, label or locator for Navigation")
 def __init__(self, parent, *text, **kwargs):
     logger = kwargs.pop('logger', None)
     Widget.__init__(self, parent, logger=logger)
     if text:
         if kwargs:
             raise TypeError('If you pass button text then do not pass anything else.')
         if len(text) == 1:
             self.locator_conditions = 'normalize-space(.)={}'.format(quote(text[0]))
         elif len(text) == 2 and text[0].lower() == 'contains':
             self.locator_conditions = 'contains(normalize-space(.), {})'.format(quote(text[1]))
         else:
             raise TypeError('An illegal combination of text params')
     else:
         # Join the kwargs
         self.locator_conditions = ' and '.join(
             '@{}={}'.format(attr, quote(value)) for attr, value in kwargs.items())
Пример #26
0
    class MyView(View):
        w = Widget()

        class AnotherView(View):
            another_widget = Widget()

        class Foo(View):
            bar = Widget()
Пример #27
0
    def __init__(self, parent, label=None, id=None, locator=None, logger=None):
        self._loaded = False
        Widget.__init__(self, parent, logger=logger)

        quoted_label = quote(label) if label else ""
        if label:
            label_part = " and @label={} or @aria-label={}".format(quoted_label, quoted_label)
        else:
            label_part = ""

        id_part = " and @id={}".format(quote(id)) if id else ""
        if locator is not None:
            self.locator = locator
        elif label_part or id_part:
            self.locator = self.LOCATOR_START.format(label_part + id_part)
        else:
            raise TypeError("You need to specify either, id, label or locator for Navigation")
Пример #28
0
 def __init__(self, parent, id, number="", move_into=None, move_from=None,
         available_items="choices_chosen", chosen_items="members_chosen", logger=None):
     Widget.__init__(self, parent, logger=logger)
     self.available_options = Select(self, id=available_items)
     self.chosen_options = Select(self, id=chosen_items)
     self.id = id
     if number:
         self.number = "[{}]".format(number)
     else:
         self.number = number
     if isinstance(move_into, WidgetDescriptor):
         self._move_into = move_into.klass(self, **move_into.kwargs)
     else:
         self._move_into = move_into
     if isinstance(move_from, WidgetDescriptor):
         self._move_from = move_from.klass(self, **move_from.kwargs)
     else:
         self._move_from = move_from
Пример #29
0
 def __init__(self, parent, locator, logger=None):
     Widget.__init__(self, parent, logger=logger)
     self.locator = locator
Пример #30
0
 def __init__(self, parent, flash_div, logger=None):
     Widget.__init__(self, parent, logger=logger)
     self.flash_div = flash_div
Пример #31
0
 def __init__(self, parent, text, logger=None):
     Widget.__init__(self, parent, logger=logger)
     self.text = text
Пример #32
0
 def __init__(self, parent, parent_entity, affected_entity, logger=None):
     Widget.__init__(self, parent, logger=logger)
     self.parent_entity = parent_entity.lower()
     self.affected_entity = affected_entity.lower()
Пример #33
0
 def __init__(self, parent, locator=None, logger=None):
     """Provide default locator value if it wasn't passed"""
     if not locator:
         locator = ".//span[contains(@ng-class, 'host.subscription_global_status')]"
     Widget.__init__(self, parent, logger=logger)
     self.locator = locator
Пример #34
0
 def __init__(self, parent, logger=None):
     Widget.__init__(self, parent, logger=logger)
Пример #35
0
 def __init__(self, parent, search_root, text_access_func=None, logger=None):
     Widget.__init__(self, parent, logger=logger)
     self.search_root = search_root
     self._access_func = text_access_func
Пример #36
0
 def __init__(self, parent, logger=None):
     Widget.__init__(self, parent, logger=logger)
Пример #37
0
 def __init__(self, parent, locator=None, item_name=None, logger=None):
     Widget.__init__(self, parent, logger=logger)
     self.locator = locator
     self.item_name = item_name
Пример #38
0
 def __init__(self, parent, id, logger=None):
     Widget.__init__(self, parent, logger=logger)
     self.id = id
Пример #39
0
 def __init__(self, parent, tree_id=None, logger=None):
     Widget.__init__(self, parent, logger=logger)
     self._tree_id = tree_id
Пример #40
0
 class Foo(View):
     bar = Widget()
 def __init__(self, parent, show_loc=None, logger=None):
     Widget.__init__(self, parent, logger=logger)
     self.show_loc = show_loc
Пример #42
0
 class AView1(View):
     widget1 = Widget()
Пример #43
0
 def __init__(self, parent, type_, logger=None):
     Widget.__init__(self, parent, logger=logger)
     if type_ not in ["Scope", "Expression"]:
         raise ValueError("Type should be Scope or Expression only")
     else:
         self.type = type_
 def __init__(self, parent, locator=None, logger=None):
     Widget.__init__(self, parent=parent, logger=logger)
     self._locator = locator or self.ROOT
Пример #45
0
        class widgets(ParametrizedView):  # noqa
            PARAMETERS = ('title', )
            ALL_LOCATOR = '//div[starts-with(@id, "w_")]//h2[contains(@class, "card-pf-title")]'
            BLANK_SLATE = './/div[contains(@class, "blank-slate-pf")]//h1'
            CHART = './div/div/div[starts-with(@id, "miq_widgetchart_")]'
            RSS = './div/div[contains(@class, "rss_widget")]'
            RSS_TABLE = './div[./div[contains(@class, "rss_widget")]]/div/table'
            TABLE = './div/table|./div/div/table'
            MC = (
                './/div[contains(@class, "mc")]/*[1]|.//div[starts-with(@id, "dd_w") '
                'and contains(@id, "_box")]/*[1]')
            ROOT = ParametrizedLocator(
                './/div[starts-with(@id, "w_") and .//h2[contains(@class, "card-pf-title")'
                ' and normalize-space(.)={title|quote}]]')

            title = Text('.//h2[contains(@class, "card-pf-title")]')
            menu = Kebab(button_id=ParametrizedString('btn_{@widget_id}'))

            contents = ConditionalSwitchableView(reference='content_type')

            # Unsupported reading yet
            contents.register(None, default=True, widget=Widget())
            contents.register('chart', widget=Widget())

            # Reading supported
            contents.register('table', widget=Table(TABLE))
            contents.register('rss', widget=Table(RSS_TABLE))

            footer = Text('.//div[contains(@class, "card-pf-footer")]')

            @property
            def column(self):
                """Returns the column position of this widget. Numbered from 1!"""
                if self.browser.product_version < "5.10":
                    parent = self.browser.element('..')
                else:
                    parent = self.browser.element('../../..')
                try:
                    parent_id = self.browser.get_attribute('id',
                                                           parent).strip()
                    return int(re.sub(r'^col(\d+)$', '\\1', parent_id))
                except (ValueError, TypeError, AttributeError):
                    raise ValueError(
                        'Could not get the column index of widget')

            @property
            def minimized(self):
                return not self.browser.is_displayed(self.MC)

            @cached_property
            def widget_id(self):
                id_attr = self.browser.get_attribute('id', self)
                return int(id_attr.rsplit('_', 1)[-1])

            @cached_property
            def content_type(self):
                if self.browser.elements(self.BLANK_SLATE):
                    # No data yet
                    return None
                elif self.browser.elements(self.RSS):
                    return 'rss'
                elif self.browser.is_displayed(self.CHART):
                    return 'chart'
                elif self.browser.is_displayed(self.TABLE):
                    return 'table'
                else:
                    return None

            @property
            def blank(self):
                return bool(self.browser.elements(self.BLANK_SLATE))

            @classmethod
            def all(cls, browser):
                return [(browser.text(e), )
                        for e in browser.elements(cls.ALL_LOCATOR)]
Пример #46
0
 def __init__(self, parent, type_, logger=None):
     Widget.__init__(self, parent, logger=logger)
     if type_ not in ["Scope", "Expression"]:
         raise ValueError("Type should be Scope or Expression only")
     else:
         self.type = type_