08ea5fbe98
添加用户管理视图、API和状态管理文件
150 lines
4.6 KiB
Python
150 lines
4.6 KiB
Python
"""
|
|
黄历页面
|
|
|
|
Uniapp黄历页面的页面对象模型。
|
|
"""
|
|
|
|
from playwright.sync_api import Page
|
|
from ..base_page import BasePage
|
|
|
|
|
|
class AlmanacPage(BasePage):
|
|
"""黄历页面"""
|
|
|
|
# 页面路径
|
|
PATH = "/pages/almanac/index"
|
|
|
|
# 元素定位器
|
|
LOCATORS = {
|
|
"page_title": ".page-title",
|
|
"date_display": ".date-display",
|
|
"solar_date": ".solar-date",
|
|
"lunar_date": ".lunar-date",
|
|
"ganzhi": ".ganzhi",
|
|
"shengxiao": ".shengxiao",
|
|
"yi_list": ".yi-list",
|
|
"ji_list": ".ji-list",
|
|
"yi_items": ".yi-item",
|
|
"ji_items": ".ji-item",
|
|
"shichen_table": ".shichen-table",
|
|
"shichen_rows": ".shichen-row",
|
|
"chongsha": ".chongsha",
|
|
"wuxing": ".wuxing",
|
|
"taishen": ".taishen",
|
|
"caishen": ".caishen",
|
|
"prev_date_btn": ".prev-date",
|
|
"next_date_btn": ".next-date",
|
|
"date_picker": ".date-picker",
|
|
"search_btn": ".search-btn",
|
|
"tab_calendar": ".tab-calendar",
|
|
"tab_almanac": ".tab-almanac",
|
|
"tab_user": ".tab-user",
|
|
}
|
|
|
|
def __init__(self, page: Page, base_url: str = ""):
|
|
super().__init__(page, base_url)
|
|
|
|
def navigate(self, path: str = "") -> None:
|
|
"""导航到黄历页面"""
|
|
target_path = path if path else self.PATH
|
|
self.page.goto(f"{self.base_url}{target_path}")
|
|
self.wait_for_load()
|
|
|
|
def is_loaded(self) -> bool:
|
|
"""检查页面是否加载完成"""
|
|
return self.is_element_visible(self.LOCATORS["date_display"])
|
|
|
|
def get_solar_date(self) -> str:
|
|
"""获取公历日期"""
|
|
return self.get_text(self.LOCATORS["solar_date"])
|
|
|
|
def get_lunar_date(self) -> str:
|
|
"""获取农历日期"""
|
|
return self.get_text(self.LOCATORS["lunar_date"])
|
|
|
|
def get_ganzhi(self) -> str:
|
|
"""获取干支"""
|
|
return self.get_text(self.LOCATORS["ganzhi"])
|
|
|
|
def get_shengxiao(self) -> str:
|
|
"""获取生肖"""
|
|
return self.get_text(self.LOCATORS["shengxiao"])
|
|
|
|
def get_yi_items(self) -> list:
|
|
"""获取宜事项列表"""
|
|
items = self.page.locator(self.LOCATORS["yi_items"]).all()
|
|
return [item.text_content() for item in items]
|
|
|
|
def get_ji_items(self) -> list:
|
|
"""获取忌事项列表"""
|
|
items = self.page.locator(self.LOCATORS["ji_items"]).all()
|
|
return [item.text_content() for item in items]
|
|
|
|
def get_yi_count(self) -> int:
|
|
"""获取宜事项数量"""
|
|
return self.get_elements_count(self.LOCATORS["yi_items"])
|
|
|
|
def get_ji_count(self) -> int:
|
|
"""获取忌事项数量"""
|
|
return self.get_elements_count(self.LOCATORS["ji_items"])
|
|
|
|
def click_prev_date(self) -> None:
|
|
"""点击前一天"""
|
|
self.click_element(self.LOCATORS["prev_date_btn"])
|
|
|
|
def click_next_date(self) -> None:
|
|
"""点击后一天"""
|
|
self.click_element(self.LOCATORS["next_date_btn"])
|
|
|
|
def click_date_picker(self) -> None:
|
|
"""点击日期选择器"""
|
|
self.click_element(self.LOCATORS["date_picker"])
|
|
|
|
def click_search(self) -> None:
|
|
"""点击搜索按钮"""
|
|
self.click_element(self.LOCATORS["search_btn"])
|
|
|
|
def click_tab_calendar(self) -> None:
|
|
"""点击万年历Tab"""
|
|
self.click_element(self.LOCATORS["tab_calendar"])
|
|
|
|
def click_tab_almanac(self) -> None:
|
|
"""点击黄历Tab"""
|
|
self.click_element(self.LOCATORS["tab_almanac"])
|
|
|
|
def click_tab_user(self) -> None:
|
|
"""点击我的Tab"""
|
|
self.click_element(self.LOCATORS["tab_user"])
|
|
|
|
def get_chongsha(self) -> str:
|
|
"""获取冲煞信息"""
|
|
return self.get_text(self.LOCATORS["chongsha"])
|
|
|
|
def get_wuxing(self) -> str:
|
|
"""获取五行信息"""
|
|
return self.get_text(self.LOCATORS["wuxing"])
|
|
|
|
def get_taishen(self) -> str:
|
|
"""获取胎神信息"""
|
|
return self.get_text(self.LOCATORS["taishen"])
|
|
|
|
def get_caishen(self) -> str:
|
|
"""获取财神方位"""
|
|
return self.get_text(self.LOCATORS["caishen"])
|
|
|
|
def get_shichen_count(self) -> int:
|
|
"""获取时辰数量"""
|
|
return self.get_elements_count(self.LOCATORS["shichen_rows"])
|
|
|
|
def has_yi_section(self) -> bool:
|
|
"""检查是否有宜事项区域"""
|
|
return self.is_element_visible(self.LOCATORS["yi_list"])
|
|
|
|
def has_ji_section(self) -> bool:
|
|
"""检查是否有忌事项区域"""
|
|
return self.is_element_visible(self.LOCATORS["ji_list"])
|
|
|
|
def wait_for_data_load(self, timeout: int = 10000) -> None:
|
|
"""等待数据加载完成"""
|
|
self.wait_for_selector(self.LOCATORS["solar_date"], timeout=timeout)
|