54 lines
2.1 KiB
Python
54 lines
2.1 KiB
Python
from playwright.sync_api import Page
|
|
|
|
from components.base_component import BaseComponent
|
|
from elements.button_element import Button
|
|
from elements.text_element import Text
|
|
from locators.confirm_locators import ConfirmLocators
|
|
|
|
from tools.logger import get_logger
|
|
|
|
logger = get_logger("CONFIRM_WINDOW")
|
|
|
|
|
|
class ConfirmComponent(BaseComponent):
|
|
"""Компонент окна подтверждения действий."""
|
|
|
|
def __init__(self, page: Page, cancel_button_text: str, allow_button_text: str):
|
|
super().__init__(page)
|
|
|
|
self.title = Text(page, ConfirmLocators.TITLE, "confirm title")
|
|
self.text = Text(page, ConfirmLocators.TEXT, "confirm text")
|
|
|
|
self.close_button = Button(page, ConfirmLocators.BUTTON_CLOSE, "confirm close button")
|
|
self.cancel_button = Button(
|
|
page,
|
|
page.get_by_role("button", name=cancel_button_text).first,
|
|
"confirm cancel button"
|
|
)
|
|
self.allow_button = Button(
|
|
page,
|
|
page.get_by_role("button", name=allow_button_text).first,
|
|
"confirm allow button"
|
|
)
|
|
|
|
# Действия:
|
|
def click_allow_button(self) -> None:
|
|
"""Нажатие кнопки подтверждения действия."""
|
|
self.allow_button.click()
|
|
|
|
def click_cancel_button(self) -> None:
|
|
"""Нажатие кнопки отмены действия."""
|
|
self.cancel_button.click()
|
|
|
|
def click_close_button(self) -> None:
|
|
"""Нажатие кнопки закрытия окна подтверждения."""
|
|
self.close_button.click()
|
|
|
|
# Проверки:
|
|
def check_title(self, title: str, msg: str) -> None:
|
|
"""Проверка текста заголовка окна подтверждения."""
|
|
self.title.check_have_text(title, msg)
|
|
|
|
def check_text(self, text: str, msg: str) -> None:
|
|
"""Проверка текста сообщения в окне подтверждения."""
|
|
self.text.check_have_text(text, msg) |