08ea5fbe98
添加用户管理视图、API和状态管理文件
104 lines
3.2 KiB
Python
104 lines
3.2 KiB
Python
"""
|
|
用户页面
|
|
|
|
Uniapp用户页面的页面对象模型。
|
|
"""
|
|
|
|
from playwright.sync_api import Page
|
|
from ..base_page import BasePage
|
|
|
|
|
|
class UserPage(BasePage):
|
|
"""用户页面"""
|
|
|
|
# 页面路径
|
|
PATH = "/pages/user/index"
|
|
|
|
# 元素定位器
|
|
LOCATORS = {
|
|
"page_title": ".page-title",
|
|
"user_avatar": ".user-avatar",
|
|
"user_name": ".user-name",
|
|
"user_stats": ".user-stats",
|
|
"stat_days": ".stat-days",
|
|
"stat_favorites": ".stat-favorites",
|
|
"stat_important": ".stat-important",
|
|
"menu_favorites": ".menu-favorites",
|
|
"menu_important": ".menu-important",
|
|
"menu_feedback": ".menu-feedback",
|
|
"menu_settings": ".menu-settings",
|
|
"menu_about": ".menu-about",
|
|
"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["user_avatar"])
|
|
|
|
def get_user_name(self) -> str:
|
|
"""获取用户名"""
|
|
return self.get_text(self.LOCATORS["user_name"])
|
|
|
|
def get_stat_days(self) -> str:
|
|
"""获取使用天数"""
|
|
return self.get_text(self.LOCATORS["stat_days"])
|
|
|
|
def get_stat_favorites(self) -> str:
|
|
"""获取收藏数"""
|
|
return self.get_text(self.LOCATORS["stat_favorites"])
|
|
|
|
def get_stat_important(self) -> str:
|
|
"""获取重要日期数"""
|
|
return self.get_text(self.LOCATORS["stat_important"])
|
|
|
|
def click_menu_favorites(self) -> None:
|
|
"""点击我的收藏菜单"""
|
|
self.click_element(self.LOCATORS["menu_favorites"])
|
|
|
|
def click_menu_important(self) -> None:
|
|
"""点击重要日期菜单"""
|
|
self.click_element(self.LOCATORS["menu_important"])
|
|
|
|
def click_menu_feedback(self) -> None:
|
|
"""点击意见反馈菜单"""
|
|
self.click_element(self.LOCATORS["menu_feedback"])
|
|
|
|
def click_menu_settings(self) -> None:
|
|
"""点击设置菜单"""
|
|
self.click_element(self.LOCATORS["menu_settings"])
|
|
|
|
def click_menu_about(self) -> None:
|
|
"""点击关于我们菜单"""
|
|
self.click_element(self.LOCATORS["menu_about"])
|
|
|
|
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 has_user_avatar(self) -> bool:
|
|
"""检查是否有用户头像"""
|
|
return self.is_element_visible(self.LOCATORS["user_avatar"])
|
|
|
|
def wait_for_user_data(self, timeout: int = 10000) -> None:
|
|
"""等待用户数据加载"""
|
|
self.wait_for_selector(self.LOCATORS["user_name"], timeout=timeout)
|