# Time    : 2024/7/23 16:16
# Author  : wangchao
# File    : HistoryLibraryManagement.py
# Description :
from BasePage.BasePage import BasePage


class HistoryLibraryManagement(BasePage):
	def __init__(self, page):
		super().__init__(page)
		"""
		元素定位器
		"""
		# 数据备份
		self.history_library_edite_pop_up_window_locator = page.locator("div:nth-child(2) > .custom-tree-node > .node > .btn > .iconfont") # 点击“历史组01”编辑菜单
		self.history_library_backup_button_locator = page.get_by_text("数据备份") # 点击“历史组01”编辑菜单中的“数据备份”
		self.history_library_backup_success_toast_locator = page.locator("//*[@id=\"message_1\"]") # 备份成功
		# 数据清除
		self.history_library_clear_button_locator = page.get_by_text("数据清除") # 点击“历史组01”编辑菜单中的“数据清除”
		self.history_library_clear_success_toast_locator = page.locator("//*[@id=\"message_1\"]") # 清除成功
		self.history_library_clear_confirm_button_locator = page.get_by_text("确定") # 确认清除
	"""
	页面操作
	"""

	# 历史库数据备份
	def history_library_backup(self):
		# 点击“历史组01”编辑菜单
		self._click(pw_locator=self.history_library_edite_pop_up_window_locator)
		# 点击“数据备份”
		self._click(pw_locator=self.history_library_backup_button_locator)

	# 历史库数据清除
	def history_library_clear(self):
		# 点击“历史组01”编辑菜单
		self._click(pw_locator=self.history_library_edite_pop_up_window_locator)
		self.page.on("dialog", lambda dialog: dialog.accept()) # 确定清除弹框处理
		# 点击“数据清除”
		self._click(pw_locator=self.history_library_clear_button_locator)
		# 确认清除
		self._click(pw_locator=self.history_library_clear_confirm_button_locator)