Ejemplo n.º 1
0
class HostsView(BaseLoggedInView, SearchableViewMixin):
    title = Text("//h1[text()='Hosts']")
    export = Text(
        ".//a[contains(@class, 'btn')][contains(@href, 'hosts.csv')]")
    new = Text("//a[contains(text(),'Create Host')]")
    register = PF4Button('OUIA-Generated-Button-secondary-2')
    select_all = Checkbox(locator="//input[@id='check_all']")
    table = SatTable(
        './/table',
        column_widgets={
            0: Checkbox(locator=".//input[@class='host_select_boxes']"),
            'Name': Text("./a"),
            'Actions': ActionsDropdown("./div[contains(@class, 'btn-group')]"),
        },
    )
    actions = ActionsDropdown("//div[@id='submit_multiple']")

    @property
    def is_displayed(self):
        return self.browser.wait_for_element(self.title,
                                             exception=False) is not None
Ejemplo n.º 2
0
class HostRegisterView(BaseLoggedInView):
    generate_command = PF4Button('OUIA-Generated-Button-primary-1')
    cancel = PF4Button('OUIA-Generated-Button-link-1')
    registration_command = TextInput(id='text-input-3')

    @View.nested
    class general(Tab):
        TAB_NAME = 'General'
        TAB_LOCATOR = ParametrizedLocator(
            './/div[contains(@class, "pf-c-tabs")]//ul'
            "/li[button[normalize-space(.)={@tab_name|quote}]]")
        ROOT = '//section[@id="generalSection"]'

        orgnization = FormSelect('OUIA-Generated-FormSelect-default-1')
        location = FormSelect('OUIA-Generated-FormSelect-default-2')
        host_group = FormSelect('OUIA-Generated-FormSelect-default-3')
        operating_system = FormSelect('OUIA-Generated-FormSelect-default-4')
        linux_host_init_link = Link(
            '//a[text()="Linux host_init_config default"]')
        capsule = FormSelect('OUIA-Generated-FormSelect-default-5')
        insecure = Checkbox(id='reg_insecure')

    @View.nested
    class advanced(Tab):
        TAB_NAME = 'Advanced'
        TAB_LOCATOR = ParametrizedLocator(
            './/div[contains(@class, "pf-c-tabs")]//ul'
            "/li[button[normalize-space(.)={@tab_name|quote}]]")
        ROOT = '//section[@id="advancedSection"]'

        setup_rex = FormSelect('OUIA-Generated-FormSelect-default-6')
        setup_insights = FormSelect('OUIA-Generated-FormSelect-default-7')
        install_packages = TextInput(id='reg_packages')
        repository = TextInput(id='reg_repo')
        repository_gpg_key_url = TextInput(id='reg_gpg_key_url')
        token_life_time = TextInput(id='reg_token_life_time_input')
        rex_interface = TextInput(id='reg_rex_interface_input')
        activation_keys = BaseMultiSelect(
            'OUIA-Generated-Select-typeaheadmulti-1')
        life_cycle_env = FormSelect('OUIA-Generated-FormSelect-default-8')
        ignore_error = Checkbox(id='reg_katello_ignore')
        force = Checkbox(id='reg_katello_force')

    @property
    def is_displayed(self):
        return self.browser.wait_for_element(self.general.operating_system,
                                             exception=False)

    def before_fill(self, values):
        """Fill some of the parameters in the widgets with values.

        Args:
            values: A dictionary of `widget_name: value_to_fill`.

        Note:
            Some of the fields are disabled for few seconds and get enabled based
            on the selection, handled separately
        """
        for field in ('host_group', 'operating_system'):
            field_value = values.get('general').get(field)
            if field_value:
                wait_for(
                    lambda: self.general.__getattribute__(field).is_enabled,
                    timeout=30,
                    delay=2,
                    logger=self.logger,
                )
                self.general.__getattribute__(field).fill(field_value)
        wait_for(
            lambda: self.general.linux_host_init_link.is_displayed,
            timeout=30,
            delay=2,
            logger=self.logger,
        )