class CustomLabelsView(BaseLoggedInPage):
    """This view represents Custom labels tab page"""

    paginator = Pagination(
        locator='.//div[contains(@class, "pf-c-pagination")]')
    add_label_button = Button("Add label")
    search = Input(locator=".//input[@aria-label='Filter by short path']")
    table_loading = './/div[contains(@class, "pf-c-skeleton")]'
    ACTIONS_INDEX = 2
    table = Table(
        locator='.//table[contains(@aria-label, "Table")]',
        column_widgets={
            "Short path":
            Button(locator='.//th[@data-label="Short path"]/button'),
            ACTIONS_INDEX: Dropdown(),
        },
    )

    def is_table_loaded(self):
        return wait_for(
            lambda: not self.browser.is_displayed(self.table_loading),
            delay=10,
            timeout=120)

    @property
    def is_displayed(self):
        if self.is_table_loaded():
            return self.add_label_button.is_displayed and self.table.is_displayed
        else:
            return False
class SystemRulesView(BaseLoggedInPage):
    """This view represents System rules tab page"""

    paginator = Pagination(
        locator='.//div[contains(@class, "pf-c-pagination")]')

    show_all_rules = Text(".//input[@id='showAllRules']")
    table = Table(
        locator='.//table[contains(@aria-label, "Table")]',
        column_widgets={
            "Provider ID":
            Button(locator='.//th[@data-label="Provider ID"]/button'),
            "Number of rules":
            Button(locator=".//th[@data-label='Number of rules']/button"),
            4:
            Dropdown(),
        },
    )
    filter_type_selector = DropdownMenu(
        locator='.//div[contains(@class, "pf-c-select")]')
    filter_by = MTACheckboxSelect(
        locator='.//span[@class="pf-c-select__toggle-arrow"]//parent::button['
        'contains(@aria-labelledby, "Filter by Source")]/parent::div |'
        ' .//span[@class="pf-c-select__toggle-arrow"]//parent::button['
        'contains(@aria-labelledby, "Filter by Target")]/parent::div')

    clear = Text('.//button[contains(text(), "Clear all filters")]')

    @property
    def is_displayed(self):
        return self.table.is_displayed and self.show_all_rules.is_displayed
Exemplo n.º 3
0
class CloudInsightsView(BaseLoggedInView, SearchableViewMixin):
    """Main RH Cloud Insights view."""

    title = Text('//h1[text()="Red Hat Insights"]')
    insights_sync_switcher = Switch('OUIA-Generated-Switch-1')
    remediate = Button('Remediate')
    insights_dropdown = Dropdown(
        locator='.//div[contains(@class, "title-dropdown")]')
    select_all = Checkbox(locator='.//input[@aria-label="Select all rows"]')
    table = PatternflyTable(
        component_id='OUIA-Generated-Table-2',
        column_widgets={
            0: Checkbox(locator='.//input[@type="checkbox"]'),
            'Hostname': Text('.//a'),
            'Recommendation': Text('.//a'),
            'Total Risk': Text('.//a'),
            'Playbook': Text('.//a'),
        },
    )
    select_all_hits = Button('Select recommendations from all pages')
    clear_hits_selection = Button('Clear Selection')
    pagination = Pagination()
    remediation_window = View.nested(RemediationView)

    @property
    def is_displayed(self):
        return self.title.wait_displayed()

    def search(self, query):
        """Perform search using searchbox on the page and return table
        contents.

        :param str query: search query to type into search field. E.g. ``foo``
            or ``name = "bar"``.
        :return: list of dicts representing table rows
        :rtype: list
        """
        if not hasattr(self.__class__, 'table'):
            raise AttributeError(
                f'Class {self.__class__.__name__} does not have attribute "table". '
                'SearchableViewMixin only works with views, which have table for results. '
                'Please define table or use custom search implementation instead'
            )
        self.searchbox.search(query + Keys.ENTER)
        self.table.wait_displayed()
        return self.table.read()
class SystemLabelsView(BaseLoggedInPage):
    """This view represents System labels tab page"""

    paginator = Pagination(
        locator='.//div[contains(@class, "pf-c-pagination")]')

    table = Table(
        locator='.//table[contains(@aria-label, "Table")]',
        column_widgets={
            "Provider ID":
            Button(locator='.//th[@data-label="Provider ID"]/button'),
            2:
            Dropdown(),
        },
    )
    search = Input(locator='.//input[@aria-label="Filter by provider ID"]')

    @property
    def is_displayed(self):
        return self.table.is_displayed and self.search.is_displayed
class CustomLabelsView(BaseLoggedInPage):
    """This view represents Custom labels tab page"""

    paginator = Pagination(
        locator='.//div[contains(@class, "pf-c-pagination")]')
    add_label_button = Button("Add label")
    search = Input(locator=".//input[@aria-label='Filter by short path']")
    ACTIONS_INDEX = 2
    table = Table(
        locator='.//table[contains(@aria-label, "Table")]',
        column_widgets={
            "Short path":
            Button(locator='.//th[@data-label="Short path"]/button'),
            ACTIONS_INDEX: Dropdown(),
        },
    )

    @property
    def is_displayed(self):
        return self.add_label_button.is_displayed and self.table.is_displayed
def paginator(browser):
    paginator = Pagination(browser,
                           locator=".//div[@id='pagination-options-menu-top']")
    yield paginator
    paginator.first_page()
    paginator.set_per_page(20)
def paginator(browser):
    paginator = Pagination(browser,
                           locator=".//div[@class='pf-c-pagination'][1]")
    yield paginator
    paginator.first_page()
    paginator.set_per_page(20)
def paginator(browser):
    paginator = Pagination(browser, locator=".//div[@class='pf-c-pagination'][1]")
    yield paginator
    paginator.first_page()
    paginator.set_per_page(20)