Example #1
0
class BundlePage(BasePageObject):
    """Helpers for working with bundle page"""

    bundle_id: int
    header: PageHeader
    footer: PageFooter
    config: CommonConfigMenuObj
    toolbar: CommonToolbar

    def __init__(self, driver, base_url, bundle_id: int):
        super().__init__(driver, base_url, "/bundle/{bundle_id}/main", bundle_id=bundle_id)
        self.header = PageHeader(self.driver, self.base_url)
        self.footer = PageFooter(self.driver, self.base_url)
        self.config = CommonConfigMenuObj(self.driver, self.base_url)
        self.bundle_id = bundle_id
        self.toolbar = CommonToolbar(self.driver, self.base_url)

    @allure.step('Click on the "Main" menu item')
    def open_main_menu(self) -> 'BundlePage':
        """Click on the 'Main' menu item"""
        self.find_and_click(BundleLocators.MenuNavigation.main)
        self.wait_page_is_opened()
        return self

    @allure.step('Check all fields are presented on Main page')
    def check_all_main_menu_fields_are_presented(self):
        """Check all fields on main menu page are presented"""
        self.assert_displayed_elements(
            [
                BundleMainMenuLocators.title,
                BundleMainMenuLocators.subtitle,
                BundleMainMenuLocators.text,
            ]
        )

    def check_bundle_toolbar(self, bundle_name: str):
        self.toolbar.check_toolbar_elements(["BUNDLES", bundle_name])
Example #2
0
class ServicePageMixin(BasePageObject):
    """Helpers for working with service page"""

    # /action /main etc.
    MENU_SUFFIX: str
    MAIN_ELEMENTS: list
    cluster_id: int
    service_id: int
    header: PageHeader
    footer: PageFooter
    config: CommonConfigMenuObj
    toolbar: CommonToolbar
    table: CommonTableObj
    group_config = GroupConfigList

    __ACTIVE_MENU_CLASS = 'active'

    def __init__(self, driver, base_url, cluster_id: int, service_id: int):
        if self.MENU_SUFFIX is None:
            raise AttributeError(
                'You should explicitly set MENU_SUFFIX in class definition')
        super().__init__(
            driver,
            base_url,
            "/cluster/{cluster_id}/service/{service_id}/" + self.MENU_SUFFIX,
            cluster_id=cluster_id,
            service_id=service_id,
        )
        self.header = PageHeader(self.driver, self.base_url)
        self.footer = PageFooter(self.driver, self.base_url)
        self.config = CommonConfigMenuObj(self.driver, self.base_url)
        self.cluster_id = cluster_id
        self.service_id = service_id
        self.toolbar = CommonToolbar(self.driver, self.base_url)
        self.table = CommonTableObj(self.driver, self.base_url)
        self.group_config = GroupConfigList(self.driver, self.base_url)

    @allure.step("Open Main tab by menu click")
    def open_main_tab(self) -> "ServiceMainPage":
        """Open Main tab by menu click"""
        self.find_and_click(ObjectPageMenuLocators.main_tab)
        page = ServiceMainPage(self.driver, self.base_url, self.cluster_id,
                               self.service_id)
        page.wait_page_is_opened()
        return page

    @allure.step("Open Components tab by menu click")
    def open_components_tab(self) -> "ServiceComponentPage":
        """Open Components tab by menu click"""
        self.find_and_click(ObjectPageMenuLocators.service_components_tab)
        page = ServiceComponentPage(self.driver, self.base_url,
                                    self.cluster_id, self.service_id)
        page.wait_page_is_opened()
        return page

    @allure.step("Open Configuration tab by menu click")
    def open_config_tab(self) -> "ServiceConfigPage":
        """Open Configuration tab by menu click"""
        self.find_and_click(ObjectPageMenuLocators.config_tab)
        page = ServiceConfigPage(self.driver, self.base_url, self.cluster_id,
                                 self.service_id)
        page.wait_page_is_opened()
        return page

    @allure.step("Open Group Configuration tab by menu click")
    def open_group_config_tab(self) -> "ServiceGroupConfigPage":
        """Open Group Configuration tab by menu click"""
        self.find_and_click(ObjectPageMenuLocators.group_config_tab)
        page = ServiceGroupConfigPage(self.driver, self.base_url,
                                      self.cluster_id, self.service_id)
        page.wait_page_is_opened()
        return page

    @allure.step("Open Status tab by menu click")
    def open_status_tab(self) -> "ServiceStatusPage":
        """Open Status tab by menu click"""
        self.find_and_click(ObjectPageMenuLocators.status_tab)
        page = ServiceStatusPage(self.driver, self.base_url, self.cluster_id,
                                 self.service_id)
        page.wait_page_is_opened()
        return page

    @allure.step("Open Import tab by menu click")
    def open_import_tab(self) -> "ServiceImportPage":
        """Open Import tab by menu click"""
        self.find_and_click(ObjectPageMenuLocators.import_tab)
        page = ServiceImportPage(self.driver, self.base_url, self.cluster_id,
                                 self.service_id)
        page.wait_page_is_opened()
        return page

    @allure.step("Assert that all main elements on the page are presented")
    def check_all_elements(self):
        """Assert all main elements presence"""
        self.assert_displayed_elements(self.MAIN_ELEMENTS)

    def check_service_toolbar(self, cluster_name: str, service_name: str):
        self.toolbar.check_toolbar_elements(
            ["CLUSTERS", cluster_name, "SERVICES", service_name])
Example #3
0
class HostPageMixin(BasePageObject):
    """Helpers for working with host page"""

    # /action /main etc.
    MENU_SUFFIX: str
    MAIN_ELEMENTS: list
    host_id: int
    cluster_id: int
    header: PageHeader
    footer: PageFooter
    config: CommonConfigMenuObj
    toolbar: CommonToolbar
    __ACTIVE_MENU_CLASS = 'active'

    def __init__(self,
                 driver,
                 base_url,
                 host_id: int,
                 cluster_id: Optional[int] = None):
        if self.MENU_SUFFIX is None:
            raise AttributeError(
                'You should explicitly set MENU_SUFFIX in class definition')
        super().__init__(
            driver,
            base_url,
            "/cluster/{cluster_id}/host/{host_id}/" +
            self.MENU_SUFFIX if cluster_id else "/host/{host_id}/" +
            self.MENU_SUFFIX,
            cluster_id=cluster_id,
            host_id=host_id,
        )
        self.header = PageHeader(self.driver, self.base_url)
        self.footer = PageFooter(self.driver, self.base_url)
        self.config = CommonConfigMenuObj(self.driver, self.base_url)
        self.host_id = host_id
        self.toolbar = CommonToolbar(self.driver, self.base_url)

    @allure.step('Check FQDN is equal to {fqdn}')
    def check_fqdn_equal_to(self, fqdn: str):
        """Check if fqdn on page is equal to given one"""
        def _check(element):
            real_fqdn = element.text
            assert real_fqdn == fqdn, f'Expected FQDN is {fqdn}, but FQDN in menu is {real_fqdn}'

        fqdn_element = self.find_element(ObjectPageLocators.title)
        wait_until_step_succeeds(_check,
                                 timeout=5,
                                 period=0.1,
                                 element=fqdn_element)

    def get_bundle_label(self) -> str:
        """Get text from label below FQDN"""
        return self.find_element(ObjectPageLocators.subtitle).text

    @allure.step('Open "Main" menu')
    def open_main_menu(self) -> 'HostMainPage':
        """Open 'Main' menu"""
        self.find_and_click(HostLocators.MenuNavigation.main_tab)
        page = HostMainPage(self.driver, self.base_url, self.host_id, None)
        page.wait_page_is_opened()
        return page

    @allure.step('Open "Configuration" menu')
    def open_config_menu(self) -> 'HostConfigPage':
        """Open 'Configuration' menu"""
        self.find_and_click(HostLocators.MenuNavigation.config_tab)
        page = HostConfigPage(self.driver, self.base_url, self.host_id, None)
        page.wait_page_is_opened()
        return page

    @allure.step('Open "Status" menu')
    def open_status_menu(self) -> 'HostStatusPage':
        """Open 'Status' menu"""
        self.find_and_click(HostLocators.MenuNavigation.status_tab)
        page = HostStatusPage(self.driver, self.base_url, self.host_id, None)
        page.wait_page_is_opened()
        return page

    def active_menu_is(self, menu_locator: Locator) -> bool:
        """
        Check that menu item is active
        :param menu_locator: Menu locator from HostLocators.Menu
        """
        menu_link = self.find_element(menu_locator)
        menu_class = menu_link.get_attribute("class")
        return self.__ACTIVE_MENU_CLASS in menu_class

    @allure.step("Assert that all main elements on the page are presented")
    def check_all_elements(self):
        """Assert all main elements presence"""
        self.assert_displayed_elements(self.MAIN_ELEMENTS)

    def check_host_toolbar(self, host_name: str):
        self.toolbar.check_toolbar_elements(["HOSTS", host_name])
Example #4
0
class JobPageMixin(BasePageObject):
    """Helpers for working with job page"""

    MAIN_ELEMENTS: list
    job_id: int
    toolbar: CommonToolbar

    def __init__(self, driver, base_url, job_id: int):
        super().__init__(driver, base_url, "/job/{job_id}", job_id=job_id)
        self.header = PageHeader(self.driver, self.base_url)
        self.footer = PageFooter(self.driver, self.base_url)
        self.job_id = job_id
        self.toolbar = CommonToolbar(self.driver, self.base_url)

    MAIN_ELEMENTS = [
        ObjectPageLocators.title,
        ObjectPageLocators.subtitle,
        ObjectPageLocators.text,
        JobPageLocators.start_date,
        JobPageLocators.finish_date,
        JobPageLocators.duration,
    ]

    @allure.step("Check title on the page")
    def check_title(self, expected_title: str):
        """Check title on the page"""
        self.wait_element_visible(ObjectPageLocators.title)
        current_title = self.find_element(ObjectPageLocators.title).text
        assert current_title == expected_title, f"Title should be '{expected_title}', but was {current_title}''"

    def get_job_info(self) -> DetailedPageJobInfo:
        """Get information about job from detail page"""
        invoker_objects = self.find_element(
            JobPageLocators.subtitle).text.strip().replace(' / ', '/')
        return DetailedPageJobInfo(
            name=self.find_element(JobPageLocators.title).text.strip(),
            invoker_objects=invoker_objects,
            execution_time=self.find_element(
                JobPageLocators.duration).text.strip(),
            start_date=self.find_element(
                JobPageLocators.start_date).text.strip(),
            finish_date=self.find_element(
                JobPageLocators.finish_date).text.strip(),
        )

    @allure.step('Open stdout menu')
    def open_stdout_menu(self):
        """Open menu with stdout logs"""
        self._open_menu(JobPageLocators.Menu.stdout_tab)

    @allure.step('Open stderr menu')
    def open_stderr_menu(self):
        """Open menu with stderr logs"""
        self._open_menu(JobPageLocators.Menu.stderr_tab)

    @allure.step('Click on {log_type} download button')
    def click_on_log_download(self, log_type: Literal['stderr', 'stdout']):
        """Click on log download button"""
        locator = getattr(JobPageLocators.Menu, f'{log_type}_download_btn')
        self.find_and_click(locator)

    def _open_menu(self, locator: Locator):
        self.find_and_click(locator)
        self.wait_element_attribute(locator,
                                    'class',
                                    'active',
                                    exact_match=False)
        self.wait_element_hide(CommonToolbarLocators.progress_bar)

    def check_jobs_toolbar(self, action_name: str):
        self.toolbar.check_toolbar_elements(["JOBS", action_name])
Example #5
0
class ComponentPageMixin(BasePageObject):
    """Helpers for working with Component page"""

    # /action /main etc.
    MENU_SUFFIX: str
    MAIN_ELEMENTS: list
    cluster_id: int
    service_id: int
    component_id: int
    header: PageHeader
    footer: PageFooter
    config: CommonConfigMenuObj
    toolbar: CommonToolbar
    table: CommonTableObj
    group_config = GroupConfigList

    def __init__(self, driver, base_url, cluster_id: int, service_id: int,
                 component_id: int):
        if self.MENU_SUFFIX is None:
            raise AttributeError(
                'You should explicitly set MENU_SUFFIX in class definition')
        super().__init__(
            driver,
            base_url,
            "/cluster/{cluster_id}/service/{service_id}/component/{component_id}/"
            + self.MENU_SUFFIX,
            cluster_id=cluster_id,
            service_id=service_id,
            component_id=component_id,
        )
        self.cluster_id = cluster_id
        self.service_id = service_id
        self.component_id = component_id
        self.header = PageHeader(self.driver, self.base_url)
        self.footer = PageFooter(self.driver, self.base_url)
        self.config = CommonConfigMenuObj(self.driver, self.base_url)
        self.toolbar = CommonToolbar(self.driver, self.base_url)
        self.table = CommonTableObj(self.driver, self.base_url)
        self.group_config = GroupConfigList(self.driver, self.base_url)

    @allure.step("Open Main tab by menu click")
    def open_main_tab(self) -> "ComponentMainPage":
        """Open Main tab by menu click"""
        self.find_and_click(ObjectPageMenuLocators.main_tab)
        page = ComponentMainPage(self.driver, self.base_url, self.cluster_id,
                                 self.service_id, self.component_id)
        page.wait_page_is_opened()
        return page

    @allure.step("Open Configuration tab by menu click")
    def open_config_tab(self) -> "ComponentConfigPage":
        """Open Configuration tab by menu click"""
        self.find_and_click(ObjectPageMenuLocators.config_tab)
        page = ComponentConfigPage(self.driver, self.base_url, self.cluster_id,
                                   self.service_id, self.component_id)
        page.wait_page_is_opened()
        return page

    @allure.step("Open Group Configuration tab by menu click")
    def open_group_config_tab(self) -> "ComponentGroupConfigPage":
        """Open Group Configuration tab by menu click"""
        self.find_and_click(ObjectPageMenuLocators.group_config_tab)
        page = ComponentGroupConfigPage(self.driver, self.base_url,
                                        self.cluster_id, self.service_id,
                                        self.component_id)
        page.wait_page_is_opened()
        return page

    @allure.step("Open Status tab by menu click")
    def open_status_tab(self) -> "ComponentStatusPage":
        """Open Status tab by menu click"""
        self.find_and_click(ObjectPageMenuLocators.status_tab)
        page = ComponentStatusPage(self.driver, self.base_url, self.cluster_id,
                                   self.service_id, self.component_id)
        page.wait_page_is_opened()
        return page

    @allure.step("Assert that all main elements on the page are presented")
    def check_all_elements(self):
        """Assert all main elements presence"""
        self.assert_displayed_elements(self.MAIN_ELEMENTS)

    @allure.step("Click on link {link_name}")
    def click_link_by_name(self, link_name: str):
        """Click on link by name"""
        self.wait_element_hide(CommonToolbarLocators.progress_bar)
        self.wait_element_visible(CommonToolbarLocators.admin_link)
        self.find_and_click(
            CommonToolbarLocators.text_link(link_name.upper().strip("_")))

    def check_component_toolbar(self, cluster_name: str, service_name: str,
                                component_name: str):
        self.toolbar.check_toolbar_elements([
            "CLUSTERS", cluster_name, "SERVICES", service_name, "COMPONENTS",
            component_name
        ])