# Time    : 2024/7/25 17:12
# Author  : wangchao
# File    : PageManagementPage.py
# Description :
import re
import time

from BasePage.BasePage import BasePage
from BuildInLibrary.BuildInLibrary import BuildInLibrary
from Config import Config


class PageManagementPage(BasePage):

	def __init__(self, page, page_name=None):
		super().__init__(page)
		"""左上画面列表定位器"""
		# 新建页面
		self.add_page_button_locator = page.get_by_title("添加画面")  # 点击新建页面按钮
		# 画面导入/导出
		self.cms_page_locator = page.locator("#app span").filter(has_text=f"{page_name}")  # 点击待导出页面，页面名称为“画面导入导出测试”
		self.export_page_button_locator = page.get_by_title("导出画面")  # 点击导出按钮
		self.import_page_button_locator = page.get_by_title("导入画面")  # 点击导入按钮
		self.cms_page_export_success_toast_locator = page.locator("//*[@id=\"message_1\"]")  # 导出成功提示
		self.cms_page_import_success_toast_locator = page.locator("//*[@id=\"message_1\"]")  # 导入成功提示

		"""左下页面对象定位器"""
		# 画面对象-矩形
		self.cms_page_object_rectangle_locator = page.locator("#app").get_by_text("矩形1") # 矩形对象
		# 画面对象-线条
		self.cms_page_object_line_locator = page.locator("#app").get_by_text("线条1") # 线条对象
		# 画面对象-静态文本
		self.cms_page_object_text_locator = page.locator("#app").get_by_text("文本1") # 文本对象

		"""顶部工具栏定位器"""
		# 缩放按钮
		self.zoom_locator = page.locator("#app").get_by_text("%")
		# 缩放-自适应
		self.screen_adaptation= page.get_by_text("适应画布")
		# 保存按钮
		self.save_button_locator = page.get_by_title("保存 Ctrl+S").locator("div")
		# 预览按钮
		self.preview_button_locator = page.get_by_title("预览 Alt+P").locator("div")
		# 撤销按钮
		self.revoke_button_locator = page.get_by_title("撤销 Ctrl+Z").locator("div")
		# 恢复按钮
		self.restore_button_locator = page.get_by_title("恢复 Ctrl+Y").locator("div")
		# 复制按钮
		self.copy_button_locator = page.get_by_title("复制 Ctrl+C").locator("div")
		# 粘贴按钮
		self.paste_button_locator = page.get_by_title("粘贴 Ctrl+V").locator("div")
		# 剪切按钮
		self.cut_button_locator = page.get_by_title("剪切 Ctrl+X").locator("div")
		# 上一层按钮
		self.upper_layer_button_locator = page.get_by_title("上一层 Ctrl+[")
		# 下一层按钮
		self.next_layer_button_locator = page.get_by_title("下一层 Ctrl+]")
		# 顶层按钮
		self.top_layer_button_locator = page.get_by_title("顶层 Ctrl+Shift+[")
		# 底层按钮
		self.under_layer_button_locator = page.get_by_title("底层 Ctrl+Shift+]")
		# 组合按钮
		self.combination_button_locator = page.get_by_title("组合 Ctrl+G")
		# 拆分按钮
		self.split_button_locator = page.get_by_title("拆分 Ctrl+Shift+G")
		# 左侧对齐按钮
		self.left_align_button_locator = page.get_by_title("左侧 Ctrl+Alt+L").locator("div")
		# 居中对齐按钮
		self.center_align_button_locator = page.get_by_title("居中 Ctrl+Alt+C").locator("div")
		# 右侧对齐按钮
		self.right_align_button_locator = page.get_by_title("右侧 Ctrl+Alt+R").locator("div")
		# 顶部对齐按钮
		self.top_align_button_locator = page.get_by_title("顶部 Ctrl+Alt+T").locator("div")
		# 中部对齐按钮
		self.middle_align_button_locator = page.get_by_title("中部 Ctrl+Alt+M").locator("div")
		# 底部对齐按钮
		self.under_align_button_locator = page.get_by_title("底部 Ctrl+Alt+B").locator("div")
		# 水平对齐按钮
		self.horizontal_align_button_locator = page.get_by_title("水平 Ctrl+Shift+H")
		# 垂直按钮
		self.vertical_align_button_locator = page.get_by_title("垂直 Ctrl+Shift+U")
		# 等宽按钮
		self.equal_width_button_locator = page.get_by_title("等宽 Ctrl+Alt+W")
		# 等高按钮
		self.wait_high_button_locator = page.get_by_title("等高 Ctrl+Alt+H")

		"""组件箱和组件定位器"""
		# 组件箱
		self.component_box_locator = page.locator("//i[@class='icon-biaozhunkongjian']")  # 标准组件图标
		# 关闭组件箱
		self.close_component_box_locator = page.get_by_role("button", name="")
		# 标准tab按钮
		self.run_tab_locator = page.get_by_role("tab", name="标准")
		# 运行tab按钮
		self.run_tab_locator = page.get_by_role("tab", name="运行")
		# 图表tab按钮
		self.chart_tab_locator = page.get_by_role("tab", name="图表")
		# 控制tab按钮
		self.control_tab_locator = page.get_by_role("tab", name="控制")
		"标准-基础组件"
		# 线条组件
		self.line_component_locator = page.locator("div").filter(has_text=re.compile(r"^线条$"))
		# 圆形组件
		self.circular_component_locator = page.locator("div").filter(has_text=re.compile(r"^圆形$"))
		# 矩形组件
		self.rectangle_component_locator = page.get_by_label("基础").locator("div").filter(has_text=re.compile(r"^矩形$"))
		# 静态文本组件
		self.static_text_component_locator = page.get_by_label("基础").locator("div").filter(has_text=re.compile(r"^静态文本$"))
		# 按钮组件
		self.button_component_locator = page.locator("div").filter(has_text=re.compile(r"^按钮$"))
		# 时间选择组件
		self.time_selection_component_locator = page.locator("div").filter(has_text=re.compile(r"^时间选择$"))
		# 输入框组件
		self.input_box_component_locator = page.locator("div").filter(has_text=re.compile(r"^输入框$"))
		# 下拉选择组件
		self.pull_down_selection_component_locator = page.locator("div").filter(has_text=re.compile(r"^下拉选择$"))
		"标准-读写组件"
		# 数值显示组件
		self.numerical_display_component_locator = page.locator("div").filter(has_text=re.compile(r"^数值显示$"))
		# 数值输入组件
		self.numerical_input_component_locator = page.locator("div").filter(has_text=re.compile(r"^数值输入$"))
		# 读写框组件
		self.read_write_component_locator = page.locator("div").filter(has_text=re.compile(r"^读写框$"))
		# 开关按钮组件
		self.switch_button_component_locator = page.locator("div").filter(has_text=re.compile(r"^开关按钮$"))
		# 点动按钮组件
		self.jog_button_component_locator = page.locator("div").filter(has_text=re.compile(r"^点动按钮$"))
		# 控制按钮组件
		self.control_button_component_locator = page.locator("div").filter(has_text=re.compile(r"^控制按钮$"))
		# 下拉控制组件
		self.pull_down_control_component_locator = page.locator("div").filter(has_text=re.compile(r"^下拉控制$"))
		# 单选控制组件
		self.single_choice_control_component_locator = page.locator("div").filter(has_text=re.compile(r"^单选控制$"))
		# 复选控制组件
		self.multiple_choice_control_component_locator = page.locator("div").filter(has_text=re.compile(r"^复选控制$"))
		# 动态形状组件
		self.dynamic_shape_component_locator = page.locator("div").filter(has_text=re.compile(r"^动态形状$"))
		# 动态文本组件
		self.dynamic_text_component_locator = page.locator("div").filter(has_text=re.compile(r"^动态文本$"))
		# 动态图片组件
		self.dynamic_picture_component_locator = page.locator("div").filter(has_text=re.compile(r"^动态图片$"))
		# 进度条组件
		self.progress_bar_component_locator = page.locator("div").filter(has_text=re.compile(r"^进度条$"))
		# 进度环组件
		self.progress_cycle_component_locator = page.locator("div").filter(has_text=re.compile(r"^进度环$"))
		"基础-跳转组件"
		# 水平菜单组件
		self.horizontal_menu_component_locator = page.locator("div").filter(has_text=re.compile(r"^水平菜单$"))
		# 内嵌菜单组件
		self.nested_menu_component_locator = page.locator("div").filter(has_text=re.compile(r"^内嵌菜单$"))
		# 垂直菜单组件
		self.vertical_menu_component_locator = page.locator("div").filter(has_text=re.compile(r"^垂直菜单$"))
		# 跳转菜单组件
		self.jump_button_component_locator = page.locator("div").filter(has_text=re.compile(r"^跳转按钮$"))
		# 登录按钮组件
		self.login_button_component_locator = page.locator("div").filter(has_text=re.compile(r"^登录控件$"))
		# 弹窗按钮组件
		self.popup_button_component_locator = page.locator("div").filter(has_text=re.compile(r"^弹窗按钮$"))
		# 用户信息组件
		self.user_information_component_locator = page.locator("div").filter(has_text=re.compile(r"^用户信息$"))
		"基础-容器组件"
		# 画面容器组件
		self.screen_container_component_locator = page.locator("div").filter(has_text=re.compile(r"^画面容器$"))
		# 画面轮播组件
		self.screen_rotation_component_locator = page.locator("div").filter(has_text=re.compile(r"^画面轮播$"))
		# html组件
		self.html_component_locator = page.locator("div").filter(has_text=re.compile(r"^HTML$"))
		# 网页容器组件
		self.web_container_component_locator = page.locator("div").filter(has_text=re.compile(r"^网页容器$"))
		"基础-媒体"
		self.video_surveillance_locator = page.get_by_label("媒体").locator("use")

		"运行组件"
		# 日志管理组件
		self.log_management_component_locator = page.locator("div").filter(has_text=re.compile(r"^日志管理$"))
		# 权限管理组件
		self.permission_management_component_locator = page.locator("div").filter(has_text=re.compile(r"^权限管理$"))
		# 趋势配置组件
		self.trend_configuration_component_locator = page.locator("div").filter(has_text=re.compile(r"^趋势配置$"))
		# API请求日志组件
		self.api_request_log_component_locator = page.locator("div").filter(has_text=re.compile(r"^API请求日志$"))
		# 配方管理组件
		self.formula_management_component_locator = page.locator("div").filter(has_text=re.compile(r"^配方管理$"))

		"图表组件"
		# 展示报表组件
		self.display_report_component_locator = page.locator("div").filter(has_text=re.compile(r"^展示报表$"))
		# 柱状图组件
		self.column_chart_component_locator = page.locator("div").filter(has_text=re.compile(r"^柱状图$"))
		# 条形图组件
		self.bar_chart_component_locator = page.locator("div").filter(has_text=re.compile(r"^条形图$"))
		# 堆积条形图组件
		self.stacked_bar_chart_component_locator = page.locator("div").filter(has_text=re.compile(r"^堆积条形图$"))
		# 堆积柱状图组件
		self.stacked_column_chart_component_locator = page.locator("div").filter(has_text=re.compile(r"^堆积柱状图$"))
		# 指标卡组件
		self.indicator_card_component_locator = page.locator("div").filter(has_text=re.compile(r"^指标卡$"))
		# 折线图组件
		self.line_chart_component_locator = page.locator("div").filter(has_text=re.compile(r"^折线图$"))
		# 面积图组件
		self.area_chart_component_locator = page.locator("div").filter(has_text=re.compile(r"^面积图$"))
		# 堆积面积图组件
		self.stacking_area_chart_component_locator = page.locator("div").filter(has_text=re.compile(r"^堆积面积图$"))
		# 组合图组件
		self.combination_chart_component_locator = page.locator("div").filter(has_text=re.compile(r"^组合图$"))
		# 饼图组件
		self.pie_chart_component_locator = page.locator("div").filter(has_text=re.compile(r"^饼图$"))
		# 环形图组件
		self.circular_chart_component_locator = page.locator("div").filter(has_text=re.compile(r"^环形图$"))
		# 玫瑰图组件
		self.rose_chart_component_locator = page.locator("div").filter(has_text=re.compile(r"^玫瑰图$"))
		# 表格组件
		self.form_component_locator = page.locator("div").filter(has_text=re.compile(r"^表格$"))
		# 趋势曲线组件
		self.trend_curve_component_locator = page.locator("div").filter(has_text=re.compile(r"^趋势曲线$"))
		# 仪表盘组件
		self.dashboard_component_locator = page.locator("div").filter(has_text=re.compile(r"^仪表盘$"))
		# 循环卡片组件
		self.circular_card_component_locator = page.locator("div").filter(has_text=re.compile(r"^循环卡片$"))

		"控制组件"
		# 时间控件组件
		self.time_control_component_locator = page.locator("div").filter(has_text=re.compile(r"^时间控件$"))
		# 下拉列表组件
		self.dropdown_list_component_locator = page.locator("div").filter(has_text=re.compile(r"^下拉列表$"))
		# 导出按钮组件
		self.export_button_component_locator = page.locator("div").filter(has_text=re.compile(r"^导出按钮$"))
		# 筛选器组件
		self.filter_component_locator = page.locator("div").filter(has_text=re.compile(r"^筛选器$"))
		# 数值筛选组件
		self.numerical_filtering_component_locator = page.locator("div").filter(has_text=re.compile(r"^数值筛选$"))
		# 查询按钮组件
		self.search_button_component_locator = page.locator("div").filter(has_text=re.compile(r"^查询按钮$"))
		# 文本输入组件
		self.text_input_component_locator = page.locator("div").filter(has_text=re.compile(r"^文本输入$"))
		# 全屏切换组件
		self.full_screen_component_locator = page.locator("div").filter(has_text=re.compile(r"^全屏切换$"))
		# 语言切换组件
		self.language_switching_component_locator = page.locator("div").filter(has_text=re.compile(r"^语言切换$"))
		# 关机组件
		self.shutdown_component_locator = page.locator("div").filter(has_text=re.compile(r"^关机组件$"))
		# 虚拟键盘组件
		self.virtual_keyboard_component_locator = page.locator("div").filter(has_text=re.compile(r"^虚拟键盘$"))

		"""通用属性-位置属性"""
		# 定位X轴输入框
		self.x_axis_locator = page.locator("div").filter(has_text=re.compile(r"^X$")).get_by_role("spinbutton")
		# 定位Y轴输入框
		self.y_axis_locator = page.locator("div").filter(has_text=re.compile(r"^Y$")).get_by_role("spinbutton")
		# 定位旋转输入框
		self.rotation_locator = page.locator("div").filter(has_text=re.compile(r"^°$")).get_by_role("spinbutton")
		# 定位W位置
		self.w_locator = page.locator("div").filter(has_text=re.compile(r"^W$")).get_by_role("spinbutton")
		# 定位H位置
		self.h_locator = page.locator("div").filter(has_text=re.compile(r"^H$")).get_by_role("spinbutton")
		# 定位锁定按钮
		self.lock_locator = page.get_by_title("解锁").nth(2)

		"""通用属性-外观属性"""
		"颜色选择弹窗"
		# 定位OK按钮(关闭颜色选择器窗口)
		self.color_selection_window_ok_button_locator = page.get_by_role("button", name="OK")
		"背景"
		# 定位纯色背景按钮
		self.solid_color_background_locator = page.get_by_label("外观").locator("div").filter(has_text=re.compile(r"^背景$")).locator("span").nth(1)
		# 定位红色快捷按钮
		self.red_shortcut_button_locator = page.locator("div:nth-child(18) > div > .el-color-predefine > .el-color-predefine__colors > div:nth-child(4) > div")
		# 定位渐变/图片按钮
		self.gradient_and_picture_button_locator = page.get_by_label("外观").locator("use")
		# 定位渐变色按钮
		self.gradient_button_locator = page.get_by_label("外观").get_by_title("线性渐变")
		# 定位添加图片按钮
		self.add_image_locator = page.locator("//span[text()=\"添加图片\"]").nth(1)
		# 定位图库中默认分组的第一张图片
		self.image_locator = page.locator("//div[@class='component-gallery-material-list']//div[1]//div[1]//img[1]")
		# 定位图片的下拉框按钮
		self.image_select_button_locator = page.get_by_role("textbox", name="Select")
		# 定位拉伸类型
		self.image_stretch_type_locator = page.get_by_text("拉伸").nth(1)
		# 定位自适应类型
		self.image_adapt_type_locator = page.get_by_text("自适应").nth(1)
		# 定位实际大小类型
		self.image_actual_type_locator = page.get_by_text("实际大小").nth(1)
		# 定位覆盖类型
		self.image_cover_type_locator = page.get_by_text("覆盖").nth(1)
		"边框"
		# 定位边框类型的下拉框按钮
		self.frame_type_button_locator = page.get_by_placeholder(" ")
		# 定位直线类型
		self.straight_line_frame_locator = page.get_by_text("直线")
		# 定位圆点类型
		self.circular_dots_frame_locator = page.get_by_text("圆点")
		# 定位虚线类型
		self.dashed_line_frame_locator = page.locator("div").filter(has_text=re.compile(r"^虚线$")).locator("span")
		# 定位无边框类型
		self.no_frame_locator = page.get_by_text("无", exact=True)
		# 定位宽度输入框
		self.frame_width_locator = page.locator("div").filter(has_text=re.compile(r"^边框$")).get_by_role("spinbutton")
		# 定位边框颜色
		self.frame_colour_locator = page.locator("div:nth-child(3) > .el-color-picker > .el-color-picker__trigger > .el-color-picker__color > .el-color-picker__color-inner").first
		# 定位边框颜色-设置红色
		self.frame_red_colour_locator = page.locator("div:nth-child(30) > div > .el-color-predefine > .el-color-predefine__colors > div:nth-child(4) > div")
		"阴影"
		# 定位外阴影按钮
		self.external_shadow_button_locator = page.get_by_title("外阴影")
		# 定位外阴影模糊度，25度
		self.external_shadow_ambiguity_locator = page.get_by_role("slider", name="slider between 0 and 50").locator("div").first
		# 定位外阴影颜色选择器按钮
		self.color_selector_for_external_shadows_locator = page.get_by_role("tooltip", name="水平： 0 0 垂直： 0 0 模糊： 25 0 大小：").locator("span").nth(1)
		# 定位外阴影颜色，红色
		self.color_of_external_shadow_locator =page.locator("div:nth-child(37) > div > .el-color-predefine > .el-color-predefine__colors > div:nth-child(4) > div")
		# 定位内阴影按钮
		self.internal_shadow_button_locator = page.get_by_title("内阴影（可能被内部内容遮挡）")
		# 定位内阴影模糊度，25度
		self.internal_shadow_ambiguity_locator = page.get_by_role("slider", name="slider between 0 and 50").locator("div").first
		# 定位内阴影颜色选择器按钮
		self.color_selector_for_internal_shadows_locator = page.get_by_role("tooltip", name="水平： 0 0 垂直： 0 0 模糊： 25 0 大小：").locator("span").nth(1)
		# 定位内阴影颜色，绿色
		self.color_of_internal_shadow_locator = page.locator("div:nth-child(43) > div > .el-color-predefine > .el-color-predefine__colors > div:nth-child(6) > div")
		"圆角"
		# 定位圆角输入框
		self.rounded_corners_locator = page.locator("div").filter(has_text=re.compile(r"^圆角$")).get_by_role("spinbutton")
		"不透明度"
		# 定位不透明度
		self.opacity_locator = page.get_by_role("slider", name="slider between 0 and").locator("div").nth(1)

		"""通用属性-文本属性"""
		# 定位字号按钮
		self.font_size_locator = page.get_by_label("文本").get_by_role("img").first
		# 定位36号字体
		self.font_size_36_locator = page.get_by_text("36", exact=True)
		# 定位字体颜色按钮
		self.font_color_button_locator = page.locator("div:nth-child(2) > .el-color-picker > .el-color-picker__trigger > .el-color-picker__color > .el-color-picker__color-inner").first
		# 定位字体颜色，红色
		self.red_font_color_button_locator = page.locator("div:nth-child(46) > div > .el-color-predefine > .el-color-predefine__colors > div:nth-child(4) > div")
		# 定位对齐方式按钮
		self.align_button_locator =page.get_by_label("文本").get_by_role("img").nth(1)
		# 左对齐
		self.left_aligned_locator = page.get_by_role("tooltip", name="  ").locator("i").nth(1)
		# 居中对齐
		self.center_aligned_locator = page.get_by_role("tooltip", name="  ").locator("i").nth(2)
		# 右对齐
		self.right_aligned_locator = page.get_by_role("tooltip", name="  ").locator("i").nth(3)
		# 加粗
		self.bold_locator =page.locator("//i[@title=\"粗体 Ctrl+B\"]")
		# 斜体
		self.italic = page.locator("//i[@title=\"斜体 Ctrl+I\"]")
		# 下划线
		self.underline = page.locator("//i[@title=\"下划线 Ctrl+U\"]")
		# 定位字体类型按钮
		self.font_type_button_locator = page.get_by_label("文本").get_by_role("img").nth(2)
		# 定位手写体类型
		self.handwritten_font_locator = page.get_by_text("手写体")
		# 定位字距
		self.font_distance_locator = page.locator("div").filter(has_text=re.compile(r"^字距$")).get_by_role("spinbutton")
		# 定位行高
		self.font_row_heigh_locator = page.locator("div").filter(has_text=re.compile(r"^行高$")).get_by_role("spinbutton")


	"""画面通用属性设置（位置、外观、文本）"""
	def location_attribute_set_x_axis(self,set_value):
		"""
		位置属性：设置X
		:param set_value:
		"""
		self._click(pw_locator=self.x_axis_locator) # 定位x轴输入框
		self._fill(set_value,pw_locator=self.x_axis_locator) # 修改x


	def location_attribute_set_y_axis(self, set_value):
		"""
		位置属性：设置Y
		:param set_value:
		"""
		self._click(pw_locator=self.y_axis_locator) # 定位y轴输入框
		self._fill(set_value, pw_locator=self.y_axis_locator) # 修改y

	def location_attribute_set_rotation_angle(self, set_value):
		"""
		位置属性：设置旋转角度
		:param set_value:
		"""
		self._click(pw_locator=self.rotation_locator) # 定位旋转输入框
		self._fill(set_value, pw_locator=self.rotation_locator) # 修改旋转角度


	def location_attribute_set_width(self, set_value):
		"""
		位置属性：设置W
		:param set_value:
		"""
		self._click(pw_locator=self.w_locator) # 定位W轴输入框
		self._fill(set_value, pw_locator=self.w_locator) # 修改W

	# 位置属性修改(高)
	def location_attribute_set_high(self, set_value):
		"""
		位置属性：设置H
		:param set_value:
		"""
		self._click(pw_locator=self.h_locator) # 定位H输入框
		self._fill(set_value, pw_locator=self.h_locator) # 修改H

	def location_attribute_set_lock(self):
		"""
		位置属性：设置为锁定状态
		"""
		self._click(pw_locator=self.lock_locator) # 定位锁定按钮

	def appearance_attribute_set_solid_color_background(self):
		"""
		外观属性：设置纯色背景，默认是红色
		"""
		self._click(pw_locator=self.solid_color_background_locator) #纯色背景
		self._click(pw_locator=self.red_shortcut_button_locator) #设置红色
		self._click(pw_locator=self.color_selection_window_ok_button_locator) #关闭颜色选择器弹窗

	def appearance_attribute_set_gradient_color_background(self):
		"""
		外观属性：设置渐变色背景
		"""
		self._click(pw_locator=self.gradient_and_picture_button_locator)
		self._click(pw_locator=self.gradient_button_locator) #点击渐变色按钮
		self._click(pw_locator=self.gradient_button_locator) #再次点击，使其关闭弹窗

	def appearance_attribute_set_image_background_stretch_type(self):
		"""
		外观属性：设置图片背景，且为拉伸类型
		"""
		self._click(pw_locator=self.gradient_and_picture_button_locator) #图片背景
		self._click(pw_locator=self.add_image_locator)
		self._click(pw_locator=self.image_locator)
		self._click(pw_locator=self.image_select_button_locator)
		self._click(pw_locator=self.image_stretch_type_locator) #设置为拉伸类型

	def appearance_attribute_set_image_background_actual_type(self):
		"""
		外观属性：设置图片背景，且为实际大小类型
		"""
		self._click(pw_locator=self.gradient_and_picture_button_locator) #图片背景
		self._click(pw_locator=self.add_image_locator)
		self._click(pw_locator=self.image_locator)
		self._click(pw_locator=self.image_select_button_locator)
		self._click(pw_locator=self.image_actual_type_locator) #设置为实际大小类型

	def appearance_attribute_set_image_background_cover_type(self):
		"""
		外观属性：设置图片背景，且为覆盖类型
		"""
		self._click(pw_locator=self.gradient_and_picture_button_locator) #图片背景
		self._click(pw_locator=self.add_image_locator) #定位添加图片按钮
		self._click(pw_locator=self.image_locator)
		self._click(pw_locator=self.image_select_button_locator)
		self._click(pw_locator=self.image_cover_type_locator) #设置为覆盖类型

	def appearance_attribute_set_image_background_adapt_type(self):
		"""
		外观属性：设置图片背景，且为自适应类型
		"""
		self._click(pw_locator=self.gradient_and_picture_button_locator)
		self._click(pw_locator=self.add_image_locator)
		self._click(pw_locator=self.image_locator)
		self._click(pw_locator=self.image_select_button_locator)
		self._click(pw_locator=self.image_adapt_type_locator) #设置为覆盖类型


	def appearance_attribute_set_straight_line_frame(self):
		"""
		外观属性：设置直线边框
		:return:
		"""
		self._click(pw_locator=self.frame_type_button_locator)
		self._click(pw_locator=self.straight_line_frame_locator) #直线

	def appearance_attribute_set_dashed_line_frame(self):
		"""
		外观属性：设置虚线边框
		:return:
		"""
		self._click(pw_locator=self.frame_type_button_locator)
		self._click(pw_locator=self.dashed_line_frame_locator) #虚线

	def appearance_attribute_set_scircular_dots_frame(self):
		"""
		外观属性：设置圆点边框
		:return:
		"""
		self._click(pw_locator=self.frame_type_button_locator)
		self._click(pw_locator=self.circular_dots_frame_locator) #圆点

	def appearance_attribute_set_no_frame(self):
		"""
		外观属性：设置无边框
		:return:
		"""
		self._click(pw_locator=self.frame_type_button_locator)
		self._click(pw_locator=self.no_frame_locator) #无边框

	def appearance_attribute_set_frame_width(self,value):
		"""
		外观属性：设置边框宽度
		:param value: 边框宽度
		:return:
		"""
		self._click(pw_locator=self.frame_width_locator)
		self._fill(value,pw_locator=self.frame_width_locator) #边框宽度

	def appearance_attribute_set_frame_colour(self):
		"""
		外观属性：设置边框颜色
		:return:
		"""
		self._click(pw_locator=self.frame_colour_locator)
		self._click(pw_locator=self.frame_red_colour_locator)
		self._click(pw_locator=self.color_selection_window_ok_button_locator)


	def appearance_attribute_set_external_shadow(self):
		"""
		外观属性：设置外阴影，颜色默认为红色
		:return:
		"""
		self._click(pw_locator=self.external_shadow_button_locator) #点击外阴影按钮
		self._click(pw_locator=self.external_shadow_ambiguity_locator) #设置模糊度
		self._click(pw_locator=self.color_selector_for_external_shadows_locator) #定位颜色选择器按钮
		self._click(pw_locator=self.color_of_external_shadow_locator) #设置外阴影颜色，红色
		self._click(pw_locator=self.color_selection_window_ok_button_locator) #关闭外阴影弹窗

	def appearance_attribute_set_internal_shadow(self):
		"""
		外观属性：设置内阴影，颜色默认为绿色
		:return:
		"""
		self._click(pw_locator=self.internal_shadow_button_locator) #点击内阴影按钮
		self._click(pw_locator=self.internal_shadow_ambiguity_locator) #设置模糊度
		self._click(pw_locator=self.color_selector_for_internal_shadows_locator) #定位颜色选择器按钮
		self._click(pw_locator=self.color_of_internal_shadow_locator) #设置内阴影颜色，绿色
		self._click(pw_locator=self.color_selection_window_ok_button_locator) #关闭内阴影弹窗

	def appearance_attribute_set_rounded_corners(self, value):
		"""
		外观属性：设置圆角弧度
		:param value: 弧度值
		:return:
		"""
		self._click(pw_locator=self.rounded_corners_locator)
		self._fill(value, pw_locator=self.rounded_corners_locator)

	def appearance_attribute_set_opacity(self):
		"""
		外观属性：设置不透明度
		:return:
		"""
		self._click(pw_locator=self.opacity_locator)

	def text_attribute_set_font_size(self):
		"""
		文本属性：设置字号
		:return:
		"""
		self._click(pw_locator=self.font_size_locator) #点击字号
		self._scroll_into_view_if_needed(pw_locator=self.font_size_36_locator) #滚动到36号字体位置
		self._click(pw_locator=self.font_size_36_locator) #点击36号字体

	def text_attribute_set_font_color(self):
		"""
		文本属性：设置字体颜色
		:return:
		"""
		self._click(pw_locator=self.font_color_button_locator) #点击字体颜色按钮
		self._click(pw_locator=self.red_font_color_button_locator) #设置颜色，红色
		self._click(pw_locator=self.color_selection_window_ok_button_locator) #关闭弹窗

	def text_attribute_set_left_aligned(self):
		"""
		文本属性：设置左对齐
		:return:
		"""
		self._click(pw_locator=self.align_button_locator)
		self._click(pw_locator=self.left_aligned_locator)

	def text_attribute_set_center_aligned(self):
		"""
		文本属性：设置居中对齐
		:return:
		"""
		self._click(pw_locator=self.align_button_locator)
		self._click(pw_locator=self.center_aligned_locator) # 居中

	def text_attribute_set_right_aligned(self):
		"""
		文本属性：设置右对齐
		:return:
		"""
		self._click(pw_locator=self.align_button_locator)
		self._click(pw_locator=self.right_aligned_locator) #右对齐

	def text_attribute_set_bold(self):
		"""
		文本属性：设置加粗
		:return:
		"""
		self._click(pw_locator=self.bold_locator)

	def text_attribute_set_italic(self):
		"""
		文本属性：设置斜体
		:return:
		"""
		self._click(pw_locator=self.italic)

	def text_attribute_set_underline(self):
		"""
		文本属性：设置下划线
		:return:
		"""
		self._click(pw_locator=self.underline)
		
	def text_attribute_set_font_type(self):
		"""
		文本属性：设置字体类型,默认手写体
		:return:
		"""
		self._click(pw_locator=self.font_type_button_locator)
		self._click(pw_locator=self.handwritten_font_locator) #手写体

	def text_attribute_set_font_distance(self, value):
		"""
		文本属性：设置字间距
		:param value: 间距值
		:return:
		"""
		self._click(pw_locator=self.font_distance_locator)
		self._fill(value, pw_locator=self.font_distance_locator)

	def text_attribute_set_font_row_heigh(self, value):
		"""
		文本属性：设置行高
		:param value: 行高值
		:return:
		"""
		self._click(pw_locator=self.font_row_heigh_locator)
		self._fill(value, pw_locator=self.font_row_heigh_locator)


	"""
	工具栏操作
	"""
	def save(self):
		"""
		点击保存按钮
		:return:
		"""
		self._click(pw_locator=self.save_button_locator)

	# 预览
	def preview(self):
		pass

	# 撤销
	def undo(self):
		pass

	# 恢复
	def redo(self):
		pass

	# 复制
	def copy(self):
		pass

	# 粘贴
	def paste(self):
		pass

	# 剪切
	def cut(self):
		pass

	# 上一层
	def previous_layer(self):
		pass

	# 下一层
	def next_layer(self):
		pass

	# 顶层
	def top_layer(self):
		pass

	# 底层
	def bottom_layer(self):
		pass

	# 组合
	def group(self):
		pass

	# 拆分
	def split(self):
		pass

	# 左侧对齐
	def left_align(self):
		pass

	# 居中对齐
	def center_align(self):
		pass

	# 右侧对齐
	def right_align(self):
		pass

	# 顶部对齐
	def top_align(self):
		pass

	# 中部对齐
	def middle_align(self):
		pass

	# 底部对齐
	def bottom_align(self):
		pass

	# 水平
	def horizontal(self):
		pass

	# 垂直
	def vertical(self):
		pass

	# 等宽
	def equal_width(self):
		pass

	# 等高
	def equal_height(self):
		pass

	# 解锁
	def unlock(self):
		pass

	# 显示
	def display(self):
		pass

	# 组件箱
	def component_box(self):
		pass

	# 钢笔
	def pen(self):
		pass

	# 多语言
	def multilingual(self):
		pass


	#画布缩放,自适应
	def set_adaptation_zoom(self):
		"""
		设置画布为自适应
		:return:
		"""
		self._click(pw_locator=self.zoom_locator)
		self._click(pw_locator=self.screen_adaptation)

	# 工具栏收缩
	def toolbar_collapse(self):
		pass

	# 工具栏展开
	def toolbar_expand(self):
		pass

	"""
	页面操作
	"""
	# 新建页面
	def new_page(self, page_name):
		# 点击新建页面按钮
		self._click(pw_locator=self.cms_page_locator)
		time.sleep(1)
		# 输入页面名称
		self.page.keyboard.type(page_name) # 通过键盘输入
		self.page.keyboard.press("Enter") # 按下回车键

	# 导出画面
	def export_page(self):
		# 点击待导出页面
		self._click(pw_locator=self.cms_page_locator)
		# 点击导出按钮
		self._click(pw_locator=self.export_page_button_locator)

	# 导入画面
	def import_page(self, import_file_name):
		# 点击待导入页面
		self._click(pw_locator=self.cms_page_locator)
		self.page.on("dialog", lambda dialog: dialog.accept())  # 画面导入弹窗处理
		# 点击导入按钮
		with self.page.expect_file_chooser() as fc_info:
			self._click(pw_locator=self.import_page_button_locator)
		file_chooser = fc_info.value
		file_chooser.set_files(import_file_name)

	# 基础组件_创建矩形框
	def page_component_basic_rectangle(self):
		# 点击展开组件菜单
		self._click(pw_locator=self.component_box_locator)
		# 点击矩形组件
		self._click(pw_locator=self.rectangle_component_locator)
		# 拖拉组件到画布
		self._drag_and_drop_to_user_position(self.rectangle_component_locator, Config.target_point_x, Config.target_point_y)
