e-nms_qa_automation/pages/service_status_tab.py

161 lines
5.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"""Модуль вкладки 'Статус обслуживания'.
Содержит класс ServiceStatusTab для работы с таблицей сервисов.
Позволяет проверять состояние и взаимодействовать с элементами вкладки.
"""
from playwright.sync_api import Page
from locators.table_locators import TableLocators
from components.toolbar_component import ToolbarComponent
from components.table_component import TableComponent
from pages.base_page import BasePage
class ServiceStatusTab(BasePage):
"""Класс для работы с вкладкой 'Статус обслуживания'.
Предоставляет методы для взаимодействия с таблицей сервисов и проверки
её состояния.
Args:
page: Экземпляр страницы Playwright.
"""
def __init__(self, page: Page) -> None:
"""Инициализирует компоненты вкладки 'Статус обслуживания'."""
super().__init__(page)
self.toolbar = ToolbarComponent(page, "Статус обслуживания")
self.services_table = TableComponent(page)
def get_rows_count(self) -> int:
"""Возвращает количество строк в таблице (без заголовка).
Returns:
int: Количество строк с данными.
Raises:
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
def scroll_services_table_up(self) -> None:
"""Прокручивает таблицу сервисов вверх."""
self.services_table.scroll_up(TableLocators.TABLE_SCROLL_CONTAINER)
def scroll_services_table_down(self) -> None:
"""Прокручивает таблицу сервисов вниз."""
self.services_table.scroll_down(TableLocators.TABLE_SCROLL_CONTAINER)
def check_services_table_content(self) -> None:
"""Проверяет содержимое таблицы сервисов.
Проверяет заголовки и наличие данных в таблице.
Raises:
AssertionError: Если таблица пуста или заголовки неверны.
"""
expected_headers = [
'Контейнер',
'Время создания',
'Статус',
'Время работы',
'Image ID',
'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"
def check_services_table_verticall_scrolling(self) -> bool:
"""Проверяет возможность вертикальной прокрутки таблицы.
Returns:
bool: True если прокрутка возможна, иначе False.
"""
return self.services_table.is_scrollable_vertically(
TableLocators.TABLE_SCROLL_CONTAINER
)
def check_services_table_first_row_visibility(self) -> None:
"""Проверяет видимость первой строки таблицы.
Raises:
AssertionError: Если строка не видна.
"""
self.services_table.check_first_row_visibility(TableLocators.TABLE_WORK_AREA)
def check_services_table_last_row_visibility(self) -> None:
"""Проверяет видимость последней строки таблицы.
Raises:
AssertionError: Если строка не видна.
"""
self.services_table.check_last_row_visibility(TableLocators.TABLE_WORK_AREA)
def check_services_table_row_highlighting(self, row_index: int) -> None:
"""Проверяет выделение указанной строки таблицы.
Args:
row_index: Индекс проверяемой строки.
Raises:
AssertionError: Если строка не выделена.
"""
self.services_table.check_row_highlighting(
TableLocators.TABLE_WORK_AREA,
row_index
)
def should_be_toolbar(self) -> None:
"""Проверяет наличие тулбара на вкладке.
Raises:
AssertionError: Если тулбар отсутствует.
"""
self.toolbar.check_toolbar_presence("Toolbar is missing")
def should_be_services_table(self) -> None:
"""Проверяет наличие таблицы сервисов.
Raises:
AssertionError: Если таблица отсутствует.
"""
self.services_table.check_presence(
TableLocators.TABLE_WORK_AREA,
"Service statuses table is missing"
)