Example #1
0
 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)
Example #2
0
 def __init__(self, driver, base_url):
     super().__init__(driver, base_url, "/host")
     self.header = PageHeader(self.driver, self.base_url)
     self.footer = PageFooter(self.driver, self.base_url)
     self.table = CommonTableObj(self.driver, self.base_url,
                                 HostListLocators.HostTable)
     self.host_popup = HostCreatePopupObj(self.driver, self.base_url)
Example #3
0
 def __init__(self, driver, base_url):
     if self.MENU_SUFFIX is None:
         raise AttributeError('You should explicitly set MENU_SUFFIX in class definition')
     super().__init__(driver, base_url, "/admin/" + self.MENU_SUFFIX)
     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.table = CommonTableObj(self.driver, self.base_url)
     self.toolbar = CommonToolbar(self.driver, self.base_url)
Example #4
0
 def __init__(self, driver, base_url, provider_id: int):
     if self.MENU_SUFFIX is None:
         raise AttributeError('You should explicitly set MENU_SUFFIX in class definition')
     super().__init__(driver, base_url, "/provider/{provider_id}/" + self.MENU_SUFFIX, provider_id=provider_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.provider_id = provider_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)
Example #5
0
 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)
Example #6
0
 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)
Example #7
0
    def test_check_header_user_settings_for_authorised_user(self, app_fs):
        """Test header user settings buttons for authorised user"""
        header = PageHeader(app_fs.driver, app_fs.adcm.url)
        header.click_account_button_in_header()
        header.check_account_popup()
        header.click_settings_link_in_acc_popup()
        header.wait_url_contains_path(
            AdminSettingsPage(app_fs.driver, app_fs.adcm.url).path)

        header.click_account_button_in_header()
        header.click_profile_link_in_acc_popup()
        header.wait_url_contains_path(
            ProfilePage(app_fs.driver, app_fs.adcm.url).path)

        header.click_account_button_in_header()
        header.click_logout_in_acc_popup()
        header.wait_url_contains_path(
            LoginPage(app_fs.driver, app_fs.adcm.url).path)
Example #8
0
 def test_header_help_links_for_authorised_user(self, app_fs):
     """Test header help links for authorised user"""
     params = {
         "help_link": "t.me/joinchat/",
         "docs_link": "docs.arenadata.io/adcm/"
     }
     header = PageHeader(app_fs.driver, app_fs.adcm.url)
     header.click_help_button_in_header()
     header.check_help_popup()
     with wait_for_new_window(app_fs.driver):
         header.click_ask_link_in_help_popup()
     with allure.step(f"Check new opened page: {params['help_link']}"):
         BasePageObject(app_fs.driver,
                        app_fs.adcm.url).wait_url_contains_path(
                            params["help_link"])
         close_current_tab(app_fs.driver)
     header.click_help_button_in_header()
     with wait_for_new_window(app_fs.driver):
         header.click_doc_link_in_help_popup()
     with allure.step(f"Check new opened page: {params['docs_link']}"):
         BasePageObject(app_fs.driver,
                        app_fs.adcm.url).wait_url_contains_path(
                            params["docs_link"])
Example #9
0
    def test_header_tabs_for_authorised_user(self, app_fs):
        """Test header buttons for authorised user"""
        header = PageHeader(app_fs.driver, app_fs.adcm.url)

        header.click_arenadata_logo_in_header()
        intro_page = AdminIntroPage(app_fs.driver, app_fs.adcm.url)
        header.wait_url_contains_path(intro_page.path)

        header.click_clusters_tab_in_header()
        cluster_page = ClusterListPage(app_fs.driver, app_fs.adcm.url)
        header.wait_url_contains_path(cluster_page.path)

        header.click_hostproviders_tab_in_header()
        provider_page = ProviderListPage(app_fs.driver, app_fs.adcm.url)
        header.wait_url_contains_path(provider_page.path)

        header.click_hosts_tab_in_header()
        host_page = HostListPage(app_fs.driver, app_fs.adcm.url)
        header.wait_url_contains_path(host_page.path)

        header.click_jobs_tab_in_header()
        job_page = JobListPage(app_fs.driver, app_fs.adcm.url)
        header.wait_url_contains_path(job_page.path)

        header.click_bundles_tab_in_header()
        bundle_page = BundleListPage(app_fs.driver, app_fs.adcm.url)
        header.wait_url_contains_path(bundle_page.path)

        header.click_job_block_in_header()
        job_page = JobListPage(app_fs.driver, app_fs.adcm.url)
        header.wait_url_contains_path(job_page.path)
        header.check_job_popup()
Example #10
0
 def __init__(self, driver, base_url):
     super().__init__(driver, base_url, "/provider")
     self.header = PageHeader(self.driver, self.base_url)
     self.footer = PageFooter(self.driver, self.base_url)
Example #11
0
 def __init__(self, driver, base_url):
     super().__init__(driver, base_url, "/task")
     self.header = PageHeader(self.driver, self.base_url)
     self.footer = PageFooter(self.driver, self.base_url)
     self.table = CommonTableObj(self.driver, self.base_url,
                                 TaskListLocators.Table)
Example #12
0
class JobListPage(BasePageObject):
    """Job List Page class"""
    def __init__(self, driver, base_url):
        super().__init__(driver, base_url, "/task")
        self.header = PageHeader(self.driver, self.base_url)
        self.footer = PageFooter(self.driver, self.base_url)
        self.table = CommonTableObj(self.driver, self.base_url,
                                    TaskListLocators.Table)

    def get_task_info_from_table(
            self,
            row_num: int = 0,
            *,
            full_invoker_objects_link: bool = False) -> TableTaskInfo:
        """
        Get job information from row

        :param row_num: Index of row in table
        :param full_invoker_objects_link: Use it to get full object link (with "parent" objects)
                                          or just object which invoked the action
        """
        row = self.table.get_row(row_num)
        row_locators = TaskListLocators.Table.Row
        if full_invoker_objects_link:
            invoker_objects = self.find_children(row,
                                                 row_locators.invoker_objects)
            object_link = '/'.join(obj.text.strip() for obj in invoker_objects)
        else:
            object_link = self.find_child(
                row, row_locators.invoker_objects).text.strip()
        return TableTaskInfo(
            action_name=self.find_child(row, row_locators.action_name).text,
            invoker_objects=object_link,
            start_date=self.find_child(row, row_locators.start_date).text,
            finish_date=self.find_child(row, row_locators.finish_date).text,
            status=self._get_status_from_class_string(
                self.find_child(row, row_locators.status)),
        )

    def get_task_info_from_popup(self, row_num: int = 0) -> PopupTaskInfo:
        """Get job information from list in popup"""
        job = self.header.get_single_job_row_from_popup(row_num)
        popup_locators = AuthorizedHeaderLocators.JobPopup
        return PopupTaskInfo(
            action_name=self.find_child(job,
                                        popup_locators.JobRow.job_name).text,
            status=self._get_status_from_class_string(
                self.find_child(job, popup_locators.JobRow.job_status)),
        )

    def get_all_jobs_info(self) -> List[SubTaskJobInfo]:
        """
        Returns information about all jobs
        from expanded first task's jobs list
        """
        expand_task_locators = TaskListLocators.Table.ExpandedTask
        job_rows = self.find_elements(expand_task_locators.row)
        return [
            SubTaskJobInfo(
                name=self.find_child(job,
                                     expand_task_locators.Row.job_name).text,
                status=self._get_status_from_class_string(
                    self.find_child(job, expand_task_locators.Row.job_status)),
            ) for job in job_rows
        ]

    @allure.step('Expand task in row {row_num}')
    def expand_task_in_row(self, row_num: int = 0):
        """Click on expand jobs button"""
        table_locators = TaskListLocators.Table
        row = self.table.get_row(row_num)
        self.find_child(row, table_locators.Row.expand_task).click()
        self.wait_element_visible(table_locators.ExpandedTask.block)

    @allure.step("Click on job in task's job list")
    def click_on_job(self, job_num: int = 0):
        """Click on job in expanded first task's job list"""
        expand_task_locators = TaskListLocators.Table.ExpandedTask
        job_rows = self.find_elements(expand_task_locators.row)
        assert job_num < len(job_rows), 'Not enough jobs in this task'
        self.find_child(job_rows[job_num],
                        expand_task_locators.Row.job_name).click()

    @allure.step('Click on action name')
    def click_on_action_name_in_row(self, row: WebElement):
        """Click on action name in row"""
        locator = TaskListLocators.Table.Row.action_name
        row.find_element(locator.by, locator.value).click()

    @allure.step('Select the "All" filter tab')
    def select_filter_all_tab(self):
        """Show all tasks"""
        self._select_filter(TaskListLocators.Filter.all)

    @allure.step('Select the "Running" filter tab')
    def select_filter_running_tab(self):
        """Show only running tasks"""
        self._select_filter(TaskListLocators.Filter.running)

    @allure.step('Select the "Success" filter tab')
    def select_filter_success_tab(self):
        """Show only success tasks"""
        self._select_filter(TaskListLocators.Filter.success)

    @allure.step('Select the "Failed" filter tab')
    def select_filter_failed_tab(self):
        """Show only failed tasks"""
        self._select_filter(TaskListLocators.Filter.failed)

    def _select_filter(self, filter_locator: Locator):
        """Click on filter tab and wait it is pressed"""
        self.find_and_click(filter_locator)
        self.wait_element_attribute(filter_locator, 'aria-pressed', "true")
        self.wait_element_hide(CommonToolbarLocators.progress_bar)

    @staticmethod
    def _get_status_from_class_string(status_element: WebElement) -> JobStatus:
        """Get JobStatus from @class string"""
        class_string = status_element.get_attribute('class')
        for status in JobStatus:
            if status.value in class_string:
                return status
        raise KeyError('Job status not found in class string: %s' %
                       str(class_string))

    def get_selected_filter(self):
        """Get selected filter text"""
        for filter_element in self.find_elements(
                TaskListLocators.Filter.filter_btn):
            if filter_element.get_attribute("aria-pressed") == "true":
                return filter_element.text
Example #13
0
 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)
Example #14
0
 def __init__(self, driver, base_url):
     super().__init__(driver, base_url, "/cluster")
     self.header = PageHeader(self.driver, self.base_url)
     self.footer = PageFooter(self.driver, self.base_url)
     self.table = CommonTableObj(self.driver, self.base_url,
                                 ClusterListLocators.ClusterTable)
Example #15
0
class LoginPage(BasePageObject):
    """Login Page class"""
    def __init__(self, driver, base_url):
        super().__init__(driver, base_url, "/login")
        self.header = PageHeader(self.driver, self.base_url)
        self.footer = PageFooter(self.driver, self.base_url)

    @allure.step('Check elements on login page')
    def check_all_elements(self):
        """Check elements on login page"""
        self.header.check_unauth_page_elements()
        self.assert_displayed_elements([
            LoginPageLocators.login_form_block,
            LoginPageLocators.login_input,
            LoginPageLocators.password_input,
            LoginPageLocators.login_btn,
        ])
        self.footer.check_all_elements()

    @allure.step('Get warning text on login page')
    def get_login_warning_text(self, timeout: int = None) -> str:
        """Get warning text on login page"""
        def _get_text():
            assert self.find_element(
                LoginPageLocators.login_warning).text != ""

        wait_until_step_succeeds(_get_text,
                                 period=1,
                                 timeout=timeout or self.default_loc_timeout)
        return self.find_element(LoginPageLocators.login_warning).text

    @allure.step('Check warning text on login page')
    def check_error_message(self, message):
        """Check warning text on login page"""
        self.wait_element_visible(LoginPageLocators.login_warning)
        current_error = self.get_login_warning_text()
        with allure.step(f"Check message '{message}'"):
            assert current_error == message, f"There should be error '{message}' and not '{current_error}'"

    @allure.step('Check login button unavailable')
    def check_check_login_button_unavailable(self):
        """Check login button unavailable"""
        assert self.find_element(
            LoginPageLocators.login_btn).get_attribute("disabled") == "true"

    @allure.step('Fill login form with {username}: {password}')
    def fill_login_user_form(self, username, password):
        """Fill login form"""
        self.wait_element_visible(LoginPageLocators.login_form_block)
        self.clear_by_keys(LoginPageLocators.login_input)
        self.send_text_to_element(element=LoginPageLocators.login_input,
                                  text=username)
        self.clear_by_keys(LoginPageLocators.password_input)
        self.send_text_to_element(element=LoginPageLocators.password_input,
                                  text=password)

    @allure.step('Login with {username}: {password}')
    def login_user(self, username, password):
        """Do login"""
        self.fill_login_user_form(username, password)
        self.find_and_click(locator=LoginPageLocators.login_btn)