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,