Exemplo n.º 1
0
class ConfigurationLocators:
    """Configuration page elements locators"""

    description = bys.by_xpath("//*[@placeholder='Description configuration']")
    search_field = bys.by_id("config_search_input")
    config_save_button = bys.by_class("form_config_button_save")
    app_fields_text_boxes = bys.by_tag("app-fields-textbox")
    app_fields_labels = bys.by_tag("app-fields-label")
    app_fields_map = bys.by_tag("app-fields-map")
    app_fields_password = bys.by_tag("app-fields-password")
    app_fields_textarea = bys.by_tag("app-fields-textarea")
    app_fields_json = bys.by_tag("app-fields-json")
    app_fields_list = bys.by_tag("app-fields-list")
    app_field = bys.by_tag("app-field")
    app_root_scheme = bys.by_tag("app-root-scheme")
    map_key = bys.by_xpath("//*[@formcontrolname='key']")
    map_value = bys.by_xpath("//*[@formcontrolname='value']")
    app_conf_fields = bys.by_tag("app-config-fields")
    app_conf_form = bys.by_tag("app-config-form")
    field_group = bys.by_class("field-group")
    group_title = bys.by_tag("mat-panel-title")
    map_key_field = bys.by_class('key-field')
    map_value_field = bys.by_class('value-field')
    load_marker = bys.by_class('load_complete')
    displayed_password_fields = bys.by_xpath("//div[@style='display: flex;']")
Exemplo n.º 2
0
class Cluster:
    """Cluster elements locators"""

    name = bys.by_xpath("//*[@placeholder='Cluster name']")
    prototype = bys.by_xpath("//*[@placeholder='Bundle']")
    host_tab = bys.by_xpath("//*[@adcm_test='tab_host']")
    service_tab = bys.by_xpath("//*[@test='tab_service']")
Exemplo n.º 3
0
class Service:
    """Service elements locators"""

    name = bys.by_class("mat-card-title")
    main_tab = bys.by_xpath("//*[@test='tab_main']")
    configuration_tab = bys.by_xpath("//*[@test='tab_configuration']")
    status_tab = bys.by_xpath("//*[@test='tab_status']")
    config_column = bys.by_class("mat-column-config")
Exemplo n.º 4
0
class Common:
    """List page elements locators"""

    # Addition form common elements
    add_btn = bys.by_xpath("//*[@adcm_test='create-btn']")
    options = bys.by_xpath("//*[@role='option']")
    description = bys.by_xpath("//*[@placeholder='Description']")
    save_btn = bys.by_xpath("//span[contains(., 'Save')]/parent::button")
    cancel_btn = bys.by_xpath("//span[contains(., 'Cancel')]/parent::button")
    mat_button_wrapper = bys.by_class("mat-button-wrapper")
    toppanel_button_user = bys.by_class("toppanel_button_user")
    socket = bys.by_class("socket")
    profile = bys.by_class("profile")

    # List elements common elements
    rows = bys.by_class('mat-row')
    del_btn = "//span[contains(., 'delete')]/parent::button"
    list_text = bys.by_class("mat-list-text")

    # Dialog form common elements
    dialog = bys.by_class('mat-dialog-container')
    dialog_yes = bys.by_xpath("//span[contains(text(),'Yes')]/parent::button")
    dialog_run = bys.by_xpath("//span[contains(text(),'Run')]/parent::button")
    dialog_no = bys.by_xpath("//span[contains(text(),'No')]/parent::button")

    # Error dialog elemetns
    error = bys.by_class('snack-bar-error')
    hide_err = ''

    # Action elements
    action = bys.by_xpath("//*[@adcm_test='action_btn']")

    # Configuration elements
    input_el = bys.by_tag("input")
    mat_error = bys.by_class("mat-error")
    mat_checkbox = bys.by_tag("mat-checkbox")
    mat_checkbox_class = bys.by_class("mat-checkbox")
    mat_select = bys.by_class("mat-select")
    mat_icon = bys.by_class("mat-icon")
    mat_input_element = bys.by_class("mat-input-element")
    display_names = bys.by_class("title.mat-expansion-panel-header-title")
    mat_expansion_panel = bys.by_class("mat-expansion-panel")
    textarea = bys.by_tag("textarea")
    info_icon = bys.by_class("info-icon")
    item = bys.by_class("item")
    group_field = bys.by_class("app-group-fields")
    tooltip = bys.by_tag("app-tooltip")
    mat_slide_toggle = bys.by_class("mat-slide-toggle")
    mat_raised_button = bys.by_class("mat-raised-button")
    mat_form_field = bys.by_tag("mat-form-field")

    # Common elements
    all_childs = bys.by_css("*")
    common_popup = bys.by_css("app-snack-bar")
Exemplo n.º 5
0
class ClusterDetails(Details, ListPage):

    _host = bys.by_class('add-host2cluster')
    _add_host_icon = bys.by_xpath(
        "//*[@mattooltip='Host will be added to the cluster']")

    @property
    def host_tab(self):
        self._getelement(Cluster.host_tab).click()
        return ListPage(self.driver)

    @property
    def services_tab(self):
        self._getelement(Cluster.service_tab).click()
        return ServiceList(self.driver)

    def _add_host_to_cluster(self):
        # self._getelement(self._host).click()
        self._getelement(self._add_host_icon).click()

    def click_hosts_tab(self):
        for tab in self._getelements(self._inactive_tabs):
            if tab.text.strip() == 'Hosts':
                tab.click()
                break

    def click_services_tab(self):
        return self._click_tab("Services")

    def click_add_button(self):
        self._press_add()
        self._add_host_to_cluster()
        self.close_form()

    def add_host_in_cluster(self):
        self.click_hosts_tab()
        self.click_add_button()

    def create_host_from_cluster(self, provider_name, fqdn):
        self.host_tab  # pylint: disable=W0104
        self._press_add()
        self._wait_add_form()
        self._click_element(Host.prototype)
        self._click_element(Common.options, name=provider_name)
        self._set_field_value(Host.name, fqdn)
        self._press_save()
        self.close_form()

    def _approve_action_run(self):
        self._wait_add_form()
        return self._getelement(Common.dialog_run).click()

    def run_action_by_name(self, action_name):
        actions = self._getelements(Common.action)
        for action in actions:
            if action.text == action_name:
                action.click()
                self._approve_action_run()
                break
Exemplo n.º 6
0
class Menu:
    """Top menu locators"""

    clusters = bys.by_class("topmenu_clusters")
    hostproviders = bys.by_class("topmenu_hostproviders")
    hosts = bys.by_class("topmenu_hosts")
    jobs = bys.by_class("topmenu_jobs")
    bundles = bys.by_class("topmenu_bundles")

    job_button = bys.by_xpath('//button[@mattooltip="Show success jobs"]')
Exemplo n.º 7
0
class ActionPageLocators:
    """Action page elements locators"""

    action_run_button = bys.by_xpath('//mat-card//button')
    run_action_popup = bys.by_class('cdk-overlay-pane')

    class ActionRunPopup:
        """Action run popup elements locators"""

        verbose_chbx = bys.by_xpath(
            '//mat-checkbox[./label/*[text()="Verbose"]]')
        run_btn = bys.by_xpath('//button[./*[text()=" Run "]]')
Exemplo n.º 8
0
class LoginPage(BasePage):
    login_locator = bys.by_id('login')
    passwd_locator = bys.by_id('password')
    login_form_locator = bys.by_xpath("//*[@formcontrolname='login']")
    _logout = ()
    _user = ()

    def __init__(self, driver):
        super().__init__(driver)
        self._contains_url("login")
        self._wait_element(LoginPage.login_form_locator)
        self._login = None
        self._password = None

    @allure.step('Login with {username}: {password}')
    def login(self, username, password):
        self._login = self._wait_element_present(LoginPage.login_locator)
        self._password = self._wait_element_present(LoginPage.passwd_locator)
        self._login.send_keys(username)
        self._password.send_keys(password)
        self._password.send_keys(Keys.RETURN)
        self._contains_url("admin")
        self._wait_element(Common.toppanel_button_user)
        self._wait_login_element(Common.profile)
        self._wait_login_element(Common.socket)

    @allure.step('Logout')
    def logout(self):
        self._getelement(self._user).click()
        self._getelement(self._logout).click()

    def _wait_login_element(self, locator: tuple):
        for i in range(10):
            _ = i
            try:
                self._wait_element_present(locator, 1)
                break
            except TimeoutException:
                sleep(0.1)
                self.driver.refresh()
Exemplo n.º 9
0
class ListPage(BasePage):
    """Basic methods under the lists pages"""

    _inactive_tabs = bys.by_xpath(
        "//a[@class='mat-list-item ng-star-inserted']//div[@class='mat-list-item-content']"
    )

    def _press_add(self):
        self._click_element(Common.add_btn)

    def _press_save(self):
        self._click_element(Common.save_btn)

    def _press_cancel(self):
        self._click_element(Common.cancel_btn)

    def _click_tab(self, tab_name):
        for tab in self._getelements(self._inactive_tabs):
            if tab_name == tab.text:
                tab.click()
                return True
        return None

    def _wait_add_form(self):
        self._wait_element_present(Common.dialog)

    def close_form(self):
        """Method that closed forms by click on the area near the form"""
        self._click_with_offset(Common.dialog, 500, 50)

    def get_rows(self):
        return self._getelements(Common.rows)

    def _get_option_by_name(self, name):
        opt = ''
        sleep(2)
        for _ in self._getelements(Common.options):
            if name in _.text:
                opt = _
            else:
                opt = None
        return opt

    def _click_on_option_element(self, name):
        opt = self._get_option_by_name(name)
        opt.click()

    def _delete_first_element(self):
        """Method that finds first item in list and  delete his from list"""
        self.delete_row(0)
        approve = self._getelement(Common.dialog)
        approve.is_displayed()
        self._getelement(Common.dialog_yes).click()

    @allure.step('Delete specified row by his number: {row_number}')
    def delete_row(self, row_number):
        """Deleting specified row by his number
        :param:"""
        rows = self.get_rows()
        _del = rows[row_number].find_element_by_xpath(Common.del_btn)
        _del.click()

    @allure.step('Delete all rows')
    def delete_all_rows(self):
        rows = self.get_rows()
        for row in rows:
            _del = row.find_element_by_xpath(Common.del_btn)
            _del.click()
            approve = self._getelement(Common.dialog)
            approve.is_displayed()
            self._getelement(Common.dialog_yes).click()

    @allure.step('Check if list element contains {expected_name}')
    def list_element_contains(self, expected_name):
        row = ''
        for _ in self.get_rows():
            if expected_name in _.text:
                row = _
            else:
                row = None
        return bool(row)

    @allure.step('Check if list is empty')
    def list_is_empty(self):
        try:
            self._getelements(Common.rows)
            return False
        except TimeoutException:
            return True
Exemplo n.º 10
0
 def _get_adcm_test_element(self, element_name):
     return self._getelement(
         bys.by_xpath(f"//*[@adcm_test='{element_name}']"))
Exemplo n.º 11
0
class Host:
    """Host elements locators"""

    name = bys.by_xpath("//*[@placeholder='Fully qualified domain name']")
    prototype = bys.by_xpath("//*[@placeholder='Hostprovider']")
    cluster_id = bys.by_xpath("//*[@formcontrolname='cluster_id']")
Exemplo n.º 12
0
class Provider:
    """Provider elements locators"""

    name = bys.by_xpath("//*[@placeholder='Hostprovider name']")
    prototype = bys.by_xpath("//*[@placeholder='Bundle']")
Exemplo n.º 13
0
    class ActionRunPopup:
        """Action run popup elements locators"""

        verbose_chbx = bys.by_xpath(
            '//mat-checkbox[./label/*[text()="Verbose"]]')
        run_btn = bys.by_xpath('//button[./*[text()=" Run "]]')
Exemplo n.º 14
0
 def _get_adcm_test_element(self, element_name):
     return self._getelement(
         bys.by_xpath("//*[@adcm_test='{}']".format(element_name)))