#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
@File    :   base_page.py
@Time    :   2024/11/21 14:55:10
@Author  :   dulip3ng
@Version :   1.0
@Desc    :   None
'''

from pages.locator.base_page_locator import BasePageLocator
from playwright.sync_api import Page

class BasePage:

    def __init__(self, page: Page):
        self.page = page

    def click_blank(self):
        self.page.locator(BasePageLocator.BLANK_LOC).click()

    def get_error_message(self) -> str:
        """
        获取单一报错信息
        :TODO: 未测试，暂不可用
        :return: 报错信息
        """
        msg = self.page.locator(BasePageLocator.ERROR_MESSAGE_LOC).inner_html()
        self.page.locator(BasePageLocator.ERROR_MSG_BUTTON_LOC).click()
        return msg

    def get_error_message_detail(self) -> str:
        """
        获取弹出框形式的多个报错信息
        :TODO: 未测试，暂不可用
        :return: 报错信息
        """
        detail_msg = self.page.locator(BasePageLocator.ERROR_MESSAGE_DETAIL_LOC).inner_html()
        self.page.locator(BasePageLocator.ERROR_MSG_BUTTON_LOC).click()
        return detail_msg

    def get_warning_message(self, button_name:str) -> str:
        """
        获取单一提示信息
        :param button_name:
        :return: 提示信息
        """
        warning_msg = self.page.locator(BasePageLocator.WARNING_MESSAGE_LOC).inner_html()
        self.page.locator(BasePageLocator.WARNING_MSG_BUTTON_ARGS_LOC % button_name).click()
        return warning_msg