class custom_button(ParametrizedView):  # noqa
        PARAMETERS = ("button_group",)
        _dropdown = Dropdown(text=Parameter("button_group"))

        def item_select(self, button, handle_alert=False):
            self._dropdown.item_select(button, handle_alert=handle_alert)
Ejemplo n.º 2
0
class CatalogsMultiBoxSelect(MultiBoxSelect):
    move_into_button = Button(title=Parameter("@move_into"))
    move_from_button = Button(title=Parameter("@move_from"))
Ejemplo n.º 3
0
 class MyView(View):
     my_param = Parameter("foo")
Ejemplo n.º 4
0
    class dashboards(Tab, ParametrizedView):  # noqa
        PARAMETERS = ('title', )
        ALL_LOCATOR = './/ul[contains(@class, "nav-tabs-pf")]/li/a'
        COLUMN_LOCATOR = '//div[@id="col{}"]//h2'

        tab_name = Parameter('title')

        @classmethod
        def all(cls, browser):
            return [(browser.text(e), )
                    for e in browser.elements(cls.ALL_LOCATOR)]

        def column_widget_names(self, column_index):
            """Returns names of widgets in column specified.

            Args:
                column_index: Position of the column. Numbered from 1!

            Returns:
                :py:class:`list` of :py:class:`str`
            """
            return [
                self.browser.text(e) for e in self.browser.elements(
                    self.COLUMN_LOCATOR.format(column_index))
            ]

        @ParametrizedView.nested
        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/div[contains(@class, "mc")]/*[1]|./div/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!"""
                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)]
Ejemplo n.º 5
0
 class MyView(View):
     my_param = Parameter('foo')