# -*- coding:utf-8 -*-
# 作者：齐振鋆
# 日期：2023/3/10
# 描述:
import logging
import pytest

from unit.public.UI.BasePage import BasePage

log = logging.getLogger(__name__)


class ErrorMessage(BasePage):
    def check_message(self):
        log.info('校验错误提示')
        if self.wait_element("//div[contains(@id, 'message_')]//i[contains(@class, 'el-message-icon--error')]",
                             wait_time=3) is True:
            error_message = self.get_ele_text("//div[contains(@id, 'message_')]//p/span")
            self.fail_screenshot()
            pytest.fail("监听到页面错误提示：{}".format(error_message))

    def check_details_message(self):
        log.info('校验子表')
        if self.wait_element("//div[contains(@class, 'validate-msg-pop-body')]", wait_time=3) is True:
            self.fail_screenshot()
            pytest.fail("监听到子表错误提示")
