From 4067c2f6b09187f0790694e126b8745b72d5dcc9 Mon Sep 17 00:00:00 2001 From: Radislav Date: Wed, 1 Oct 2025 15:01:37 +0300 Subject: [PATCH] =?UTF-8?q?feat(table):=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D1=83=D1=81=D1=82=D0=BE=D0=B9=20=D1=82?= =?UTF-8?q?=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D1=8B=20=D0=B2=20check=5Fcontent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - обавлен параметр check_table_not_empty для проверки пустых таблиц - обавлено логирование при пустой таблице - Сохранена обратная совместимость --- components/table_component.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/components/table_component.py b/components/table_component.py index f068f9a..f6e04ba 100644 --- a/components/table_component.py +++ b/components/table_component.py @@ -155,14 +155,22 @@ class TableComponent(BaseComponent): f"Expected events table headers {expected_headers} are not equal {actual_headers}" def check_content(self, - locator: str | Locator, - expected_headers: list[str]) -> None: + locator: str | Locator, + expected_headers: list[str], + check_table_not_empty: bool = True) -> None: """Проверяет содержимое таблицы. Проверяет заголовки и наличие данных в таблице. + Args: + locator: Локатор таблицы. + expected_headers: Список ожидаемых заголовков таблицы. + check_table_not_empty: Флаг проверки, что таблица не пустая. + По умолчанию True. + Raises: - AssertionError: Если таблица пуста или заголовки неверны. + AssertionError: Если таблица пуста (при check_table_not_empty=True) + или заголовки неверны. """ table_content = self.read(locator) @@ -170,10 +178,15 @@ class TableComponent(BaseComponent): if len(table_content) == 0: assert False, "The contents of the table are missing" + # Проверка заголовков таблицы self.check_table_headers(table_content[0], expected_headers) + # Проверка наличия данных в таблице if len(table_content) == 1: - assert False, "Table body is missing" + if check_table_not_empty: + assert False, "Table body is missing" + else: + logger.info("Таблица пустая (не содержит строк с данными)") def check_column_descending_order(self, locator: str | Locator,