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

import allure

from unit.public.UI.BasePage import BasePage

log = logging.getLogger(__name__)


class CommonElement(BasePage):
    @allure.step('关闭当前tap页面')
    def close_tap(self, tap_name=None):
        """
        关闭tap页，不传名称则关闭当前tap页
        :param tap_name: tap名称
        """
        log.info("Closing Tap")
        self.out_frame()
        tap_close_span = "//div[@id='awsui-tabs']//div[contains(@class, 'current')]/span[contains(@class, 'close')]" if tap_name is None else "//div[@id='awsui-tabs']//span[text()='{}']/following-sibling::span".format(
            tap_name)
        self.click(tap_close_span)
