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("")
Example #2
0
        class custom_labels(View):  # noqa
            title = Text(locator=".//h5[normalize-space(.)='Custom labels']")
            add_label_button = Button("Add label")
            upload_label = HiddenFileInput(
                locator='.//input[contains(@accept,".xml")]')
            enabled_button = Text(
                locator=".//label/span[contains(@class, 'pf-c-switch__toggle')]"
            )
            close_button = Button("Close")
            next_button = Button("Next")
            back_button = Button("Back")
            cancel_button = Button("Cancel")
            fill_strategy = WaitFillViewStrategy("15s")

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

            def fill(self, values):
                """
                Args:
                    values: custom label file to be uploaded
                """
                if values.get("file_label"):
                    self.expand_custom_labels.click()
                wait_for(lambda: self.next_button.is_enabled,
                         delay=0.2,
                         timeout=60)
                was_change = True
                self.after_fill(was_change)
                return was_change

            def after_fill(self, was_change):
                self.next_button.click()
class AddCustomRuleView(CustomRulesView):
    title = Text(locator=".//h1[contains(normalize-space(.), 'Add rules')]")
    upload_rule = HiddenFileInput(locator='.//input[contains(@accept,".xml")]')
    browse_button = Button("Browse")
    close_button = Button("Close")
    fill_strategy = WaitFillViewStrategy("15s")

    @property
    def is_displayed(self):
        return self.title.is_displayed and self.browse_button.is_displayed
class AddCustomLabelView(View):
    title = Text(locator=".//h1[contains(normalize-space(.), 'Add labels')]")
    upload_label = HiddenFileInput(
        locator='.//input[contains(@accept,".xml")]')
    file_uploaded = './/div[contains(@class, "pf-m-success")]'
    browse_button = Button("Browse")
    close_button = Button("Close")
    fill_strategy = WaitFillViewStrategy("15s")

    @property
    def is_displayed(self):
        return self.title.is_displayed and self.browse_button.is_displayed
class AddCustomRuleView(CustomRulesView):
    title = Text(locator=".//h1[contains(normalize-space(.), 'Add rules')]")
    upload_rule = HiddenFileInput(locator='.//input[contains(@accept,".xml")]')
    file_uploaded = './/div[contains(@class, "pf-m-success")]'
    browse_button = Button("Browse")
    close_button = Button("Close")

    @View.nested
    class server_path(MTATab):  # noqa
        TAB_NAME = "Server path"
        including_view = View.include(AddCustomRuleServerPathView, use_parent=True)

    @property
    def is_displayed(self):
        return self.title.is_displayed and self.browse_button.is_displayed
Example #6
0
    class add_applications(View):  # noqa
        title = Text(locator=".//h5[normalize-space(.)='Add applications']")
        delete_application = Text(
            locator=".//button[contains(@aria-label, 'delete-application')]")
        browse_button = Button("Browse")
        progress_bar = './/div[contains(@role, "progressbar")]'
        upload_file = HiddenFileInput(
            locator=
            './/input[@accept=".ear, .har, .jar, .rar, .sar, .war, .zip"]')

        next_button = Button("Next")
        back_button = Button("Back")
        cancel_button = Button("Cancel")
        fill_strategy = WaitFillViewStrategy("20s")

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

        def in_progress(self):
            return self.browser.is_displayed(self.progress_bar)

        def fill(self, values):
            app_list = values.get("app_list")
            env = conf.get_config("env")
            fs = FTPClientWrapper(env.ftpserver.entities.mta)
            for app in app_list:
                # Download application file to analyze
                # This part has to be here as file is downloaded temporarily
                file_path = fs.download(app)
                self.upload_file.fill(file_path)
            wait_for(lambda: self.next_button.is_enabled,
                     delay=0.2,
                     timeout=60)
            was_change = True
            self.after_fill(was_change)
            return was_change

        def after_fill(self, was_change):
            self.next_button.click()