class LoginPage(View):
    username = Input(id="username")
    password = Input(id="password")
    login_button = Text(locator=".//div/input[@id='kc-login']")
    header = Text(locator=".//img[@alt='brand']")
    logout_button = Dropdown(text="mta")

    def validate_url(self):
        """The logged in Page in both web console and operator are same
        so added a url check to differentiate in the view"""
        if self.context["object"].application.mta_context == "ViaOperatorUI":
            url = self.context["object"].application.ocphostname
        elif self.context["object"].application.mta_context == "ViaSecure":
            url = self.context["object"].application.ocpsecurehostname
        elif self.context["object"].application.mta_context == "ViaWebUI":
            url = self.context["object"].application.hostname
        return url in self.context[
            "object"].application.web_ui.widgetastic_browser.url

    @property
    def is_displayed(self):
        return (self.username.is_displayed and self.login_button.is_displayed
                ) or (self.validate_url() and self.header.is_displayed)

    def login(self, user, password):
        self.fill({"username": user, "password": password})
        self.login_button.click()
Esempio n. 2
0
class EditProjectView(AllProjectView):
    title = Text(locator=".//h1[normalize-space(.)='Project details']")
    name = Input(name="name")
    description = Input(name="description")
    save_button = Button("Save")
    cancel_button = Button("Cancel")
    fill_strategy = WaitFillViewStrategy("35s")

    @property
    def is_displayed(self):
        return self.save_button.is_displayed and self.title.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']")
    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 ApplicationsView(BaseLoggedInPage):

    title = Text(locator=".//div/h2[normalize-space(.)='Applications']")
    ACTIONS_INDEX = 2
    table = PatternflyTable(
        ".//table[contains(@class, 'pf-c-table')]",
        column_widgets={
            "Application": Text(locator=".//a"),
            "Date added": Text(locator=".//td[@data-label='Date added']"),
            ACTIONS_INDEX: Dropdown(),
        },
    )
    add_application_button = Button("Add application")
    upload_file = HiddenFileInput(
        locator='.//input[@accept=".ear, .har, .jar, .rar, .sar, .war, .zip"]'
    )
    search = Input(locator=".//input[@aria-label='Filter by name']")
    done_button = Button("Close")
    application_packages = Text(
        locator=".//wu-select-packages/h3[normalize-space(.)='Application packages']"
    )
    sort_application = Text(locator=".//th[contains(normalize-space(.), 'Application')]//i[1]")
    save_and_run_button = Button("Save and run")
    delete_button = Button("Delete")
    cancel_button = Button("Cancel")

    @property
    def is_displayed(self):
        return self.add_application_button.is_displayed and self.title.is_displayed

    def clear_search(self):
        """Clear search"""
        if self.search.value:
            self.search.fill("")
Esempio n. 5
0
    class create_project(View):  # noqa
        title = Text(locator=".//h5[normalize-space(.)='Project details']")
        name = Input(name="name")
        description = Input(locator='.//textarea[@name="description"]')
        next_button = Button("Next")
        cancel_button = Button("Cancel")
        yes_button = Button("Yes")
        no_button = Button("No")
        fill_strategy = WaitFillViewStrategy("30s")

        @property
        def is_displayed(self):
            return self.name.is_displayed and self.title.is_displayed

        def after_fill(self, was_change):
            self.next_button.click()
class AddCustomRuleServerPathView(CustomRulesView):
    rules_path = Input(id="serverPath")
    scan_recursive = Checkbox("isChecked")
    save_button = Button("Save")
    cancel_button = Button("Cancel")

    @property
    def is_displayed(self):
        return self.rules_path.is_displayed and self.cancel_button.is_displayed
Esempio n. 7
0
class AllProjectView(BaseLoggedInPage):
    """This view represent Project All View"""

    title = Text(".//div[contains(@class, 'pf-c-content')]/h1")
    search = Input(locator=".//input[@aria-label='Filter by name']")
    sort = SortSelector("class", "btn btn-default dropdown-toggle")
    table_loading = './/div[contains(@class, "pf-c-skeleton")]'

    ACTIONS_INDEX = 4
    table = PatternflyTable(
        ".//table[contains(@class, 'pf-c-table pf-m-grid-md')]",
        column_widgets={
            "Name": Text(locator=".//a"),
            "Applications": Text(locator=".//td[@data-label='Applications']"),
            "Status": Text(locator=".//td[@data-label='Status']"),
            "Description": Text(locator=".//td[@data-label='Description']"),
            ACTIONS_INDEX: Dropdown(),
        },
    )

    create_project = Button("Create project")

    @View.nested
    class no_matches(View):  # noqa
        """After search if no match found"""

        text = Text(".//div[contains(@class, 'pf-c-empty-state__body')]")

    def clear_search(self):
        """Clear search"""
        if self.search.value:
            self.search.fill("")

    @property
    def all_projects(self):
        """Returns list of all project rows"""
        return [row for row in self.table]

    @property
    def is_displayed(self):
        return self.is_empty or (
            self.create_project.is_displayed
            and self.title.text == "Projects"
            and self.table.is_displayed
            and self.validate_url()
        )

    def select_project(self, name):
        for row in self.table:
            if row.name.text == name:
                row["Name"].widget.click()

    def table_loaded(self):
        return wait_for(
            lambda: not self.browser.is_displayed(self.table_loading), delay=10, timeout=120
        )
Esempio n. 8
0
class DeleteProjectView(AllProjectView):
    title = Text(locator=".//h1[normalize-space(.)='Project details']")
    delete_project_name = Input(id="matchText")
    fill_strategy = WaitFillViewStrategy("35s")

    delete_button = Button("Delete")
    cancel_button = Button("Cancel")

    @property
    def is_displayed(self):
        return self.delete_button.is_displayed and self.title.is_displayed
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
Esempio n. 11
0
class AnalysisResultsView(BaseLoggedInPage):

    run_analysis_button = Button("Run analysis")
    title = Text(locator=".//div/h1[normalize-space(.)='Analysis results']")
    search = Input(
        locator=".//input[@aria-label='Filter by analysis id or status']")
    analysis_results = AnalysisResults()
    confirm_delete = Button("Yes")
    cancel_delete = Button("No")
    sort_analysis = Text(
        locator=".//th[contains(normalize-space(.), 'Analysis')]//button")
    table = Table(
        locator='.//table[contains(@aria-label, "Table")]',
        column_widgets={
            "Analysis": Text(locator=".//a"),
            5: Dropdown()
        },
    )

    @property
    def is_displayed(self):
        return self.run_analysis_button.is_displayed and self.title.is_displayed

    def clear_search(self):
        """Clear search"""
        self.search.fill("")

    @ParametrizedView.nested
    class analysis_row(ParametrizedView):  # noqa
        PARAMETERS = ("row", )

        analysis_number = Text(ParametrizedLocator(".//tr[{row}]/td[1]/a"))
        delete_analysis = Text(
            ParametrizedLocator(
                ".//tr[{row}]//button[@class='pf-c-button pf-m-link']"))

        @property
        def is_displayed(self):
            return self.analysis_number.is_displayed
Esempio n. 12
0
        class options(View):  # noqa
            title = Text(
                locator=".//h5[normalize-space(.)='Advanced options']")
            app_name = Input(name="inputApplicationName")
            select_target = MTASelect(
                locator='.//div/input[contains(@placeholder, "Select targets")]'
                '/ancestor::div[contains(@class, "pf-c-select")]')
            select_source = MTASelect(
                locator='.//div/input[contains(@placeholder, "Select sources")]'
                '/ancestor::div[contains(@class, "pf-c-select")]')

            export_csv = Text(
                locator=
                ".//span[./preceding-sibling::input[@aria-label='Export CSV']]"
            )
            disable_tattletale = Text(
                locator=
                ".//span[./preceding-sibling::input[@aria-label='Disable Tattletale']]"
            )
            class_not_found_analysis = Text(
                locator=".//span[./preceding-sibling::input"
                "[@aria-label='Class Not Found analysis']]")
            compatible_files_report = Text(
                locator=".//span[./preceding-sibling::input"
                "[@aria-label='Compatible Files report']]")
            exploded_app = Text(
                locator=
                ".//span[./preceding-sibling::input[@aria-label='Exploded app']]"
            )
            keep_work_dirs = Text(
                locator=
                ".//span[./preceding-sibling::input[@aria-label='Keep work dirs']]"
            )
            skip_reports = Text(
                locator=
                ".//span[./preceding-sibling::input[@aria-label='Skip reports']]"
            )
            allow_network_access = Text(
                locator=
                ".//span[./preceding-sibling::input[@aria-label='Allow network access']]"
            )
            mavenize = Text(
                locator=
                ".//span[./preceding-sibling::input[@aria-label='Mavenize']]")
            source_mode = Text(
                locator=
                ".//span[./preceding-sibling::input[@aria-label='Source mode']]"
            )

            add_button = Button("Add")
            cancel_button = Button("Cancel")
            next_button = Button("Next")
            back_button = Button("Back")
            fill_strategy = WaitFillViewStrategy("25s")

            @property
            def is_displayed(self):
                return self.title.is_displayed and self.select_target.is_displayed

            def after_fill(self, was_change):
                wait_for(lambda: self.next_button.is_enabled,
                         delay=5,
                         timeout=350)
                self.next_button.click()