From 1b925881681dc9f27a9448af0e56c9390344688f Mon Sep 17 00:00:00 2001 From: nsubbot Date: Tue, 23 Sep 2025 10:35:45 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=B8=D0=BD=D0=B8=D0=BC=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=8B=D0=B9=20=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D1=82=D0=B0=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8?= =?UTF-8?q?=D1=86=D0=B0=20-=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=D1=8B?= =?UTF-8?q?=20=D0=BE=D0=B1=D1=89=D0=B8=D0=B5=20=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=B4=D1=8B=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=BD=D1=82=D0=B0=20=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D1=81=D1=87=D0=B5=D1=82=D0=B0=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BB=D1=82=3D=D0=B8=D1=87=D0=B5=D1=81=D1=82=D0=B2=D0=B0=20?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/table_component.py | 43 +++++++++++++++++++++++++++++++++++ pages/service_status_tab.py | 28 ++--------------------- pages/session_tab.py | 9 ++------ pages/templates_tab.py | 24 ++----------------- 4 files changed, 49 insertions(+), 55 deletions(-) diff --git a/components/table_component.py b/components/table_component.py index 74f8807..df7e614 100644 --- a/components/table_component.py +++ b/components/table_component.py @@ -41,6 +41,25 @@ class TableComponent(BaseComponent): else: return None + def get_rows_count(self, locator: str | Locator) -> int: + """Возвращает количество строк в таблице (без заголовка). + + Returns: + int: Количество строк с данными. + + Raises: + AssertionError: Если таблица пуста. + """ + + table_content = self.read(locator) + rows_count = len(table_content) + + if rows_count == 0: + assert False, "The contents of the table are missing" + + return rows_count - 1 + + def read(self, locator: str | Locator) -> list[list[str]]: """Читает данные таблицы, включая заголовки. @@ -74,6 +93,30 @@ class TableComponent(BaseComponent): return table_data # Проверки: + def check_content(self, + locator: str | Locator, + expected_headers: list[str]) -> None: + """Проверяет содержимое таблицы. + + Проверяет заголовки и наличие данных в таблице. + + Raises: + AssertionError: Если таблица пуста или заголовки неверны. + """ + + table_content = self.read(locator) + + if len(table_content) == 0: + assert False, "The contents of the table are missing" + + actual_headers = table_content[0] + + assert actual_headers == expected_headers, \ + f"Expected events table headers {expected_headers} are not equal {actual_headers}" + + if len(table_content) == 1: + assert False, "Table body is missing" + def check_first_row_visibility(self, locator: str | Locator) -> None: """Проверяет видимость первой строки таблицы. diff --git a/pages/service_status_tab.py b/pages/service_status_tab.py index 5afbec6..9c3aee3 100644 --- a/pages/service_status_tab.py +++ b/pages/service_status_tab.py @@ -39,13 +39,7 @@ class ServiceStatusTab(BasePage): AssertionError: Если таблица пуста. """ - table_content = self.services_table.read(TableLocators.TABLE_WORK_AREA) - rows_count = len(table_content) - - if rows_count == 0: - assert False, "The contents of the table are missing" - - return rows_count - 1 + return self.services_table.get_rows_count(TableLocators.TABLE_WORK_AREA) def scroll_services_table_up(self) -> None: """Прокручивает таблицу сервисов вверх.""" @@ -62,9 +56,6 @@ class ServiceStatusTab(BasePage): Проверяет заголовки и наличие данных в таблице. - - - Raises: AssertionError: Если таблица пуста или заголовки неверны. """ @@ -78,21 +69,7 @@ class ServiceStatusTab(BasePage): 'Image ТЭГ' ] - table_content = self.services_table.read(TableLocators.TABLE_WORK_AREA) - - if len(table_content) == 0: - assert False, "The contents of the table are missing" - - actual_headers = table_content[0] - - self.check_equals( - actual_headers, - expected_headers, - f"Expected table headers {expected_headers} are not equal {actual_headers}" - ) - - if len(table_content) == 1: - assert False, "Table body is missing" + self.services_table.check_content(TableLocators.TABLE_WORK_AREA, expected_headers) def check_services_table_verticall_scrolling(self) -> bool: """Проверяет возможность вертикальной прокрутки таблицы. @@ -158,4 +135,3 @@ class ServiceStatusTab(BasePage): TableLocators.TABLE_WORK_AREA, "Service statuses table is missing" ) - diff --git a/pages/session_tab.py b/pages/session_tab.py index e277f9c..d2810ef 100644 --- a/pages/session_tab.py +++ b/pages/session_tab.py @@ -46,13 +46,7 @@ class SessionsTab(BasePage): AssertionError: Если таблица пуста. """ - table_content = self.sessions_table.read(TableLocators.TABLE_WORK_AREA) - rows_count = len(table_content) - - if rows_count == 0: - assert False, "The contents of the table are missing" - - return rows_count - 1 + return self.sessions_table.get_rows_count(TableLocators.TABLE_WORK_AREA) def get_delete_session_button_from_row(self, row_index: int) -> TooltipButton: """Возвращает кнопку удаления сеанса для указанной строки. @@ -229,6 +223,7 @@ class SessionsTab(BasePage): 'Адрес' ] + table_content = self.sessions_table.read(TableLocators.TABLE_WORK_AREA) len_table_content = len(table_content) diff --git a/pages/templates_tab.py b/pages/templates_tab.py index c5591ae..08351e1 100644 --- a/pages/templates_tab.py +++ b/pages/templates_tab.py @@ -132,13 +132,7 @@ class TemplatesTab(BasePage): AssertionError: Если таблица пуста. """ - table_content = self.templates_table.read(TableLocators.TABLE_WORK_AREA) - rows_count = len(table_content) - - if rows_count == 0: - assert False, "The contents of the table are missing" - - return rows_count - 1 + return self.templates_table.get_rows_count(TableLocators.TABLE_WORK_AREA) def scroll_templates_table_up(self) -> None: """Прокручивает таблицу шаблонов вверх.""" @@ -249,21 +243,7 @@ class TemplatesTab(BasePage): 'Производитель' ] - table_content = self.templates_table.read(TableLocators.TABLE_WORK_AREA) - - if len(table_content) == 0: - assert False, "The contents of the table are missing" - - actual_headers = table_content[0] - - self.check_equals( - actual_headers, - expected_headers, - f"Expected table headers {expected_headers} are not equal {actual_headers}" - ) - - if len(table_content) == 1: - assert False, "Table body is missing" + self.templates_table.check_content(TableLocators.TABLE_WORK_AREA, expected_headers) def check_templates_table_verticall_scrolling(self) -> bool: """Проверяет возможность вертикальной прокрутки таблицы.