- 16 个业务模块,856 个测试用例,40 个 E2E 测试 - 单一 React 19 前端 + PlatformSwitcher 二合一切换 - Flask 后端支持 scenario/dcloud_module/dcloud_e2e/dcloud_all 四种任务类型 - E2E 测试面板:API 全链路(8条) + UI 点击(3条) + 分步测试(3个) - SSE 实时日志流 + 飞书告警 + 定时调度 - 完整还原原 ToB 平台 TestPanel E2E 模块
70 lines
1.7 KiB
Python
70 lines
1.7 KiB
Python
"""元素状态检查 Mixin"""
|
|
|
|
|
|
class StateMixin:
|
|
"""元素状态检查相关
|
|
|
|
提供获取元素文本、检查可见性、计数等状态查询方法。
|
|
"""
|
|
|
|
def get_text(self, selector: str) -> str:
|
|
"""获取元素文本
|
|
|
|
Args:
|
|
selector: 元素选择器
|
|
|
|
Returns:
|
|
str: 元素文本内容
|
|
"""
|
|
return self.page.locator(selector).inner_text(timeout=self.timeout)
|
|
|
|
def is_visible(self, selector: str) -> bool:
|
|
"""检查元素是否可见
|
|
|
|
Args:
|
|
selector: 元素选择器
|
|
|
|
Returns:
|
|
bool: 是否可见
|
|
"""
|
|
try:
|
|
return self.page.locator(selector).is_visible(timeout=self.timeout)
|
|
except Exception:
|
|
return False
|
|
|
|
def is_enabled(self, selector: str) -> bool:
|
|
"""检查元素是否可用
|
|
|
|
Args:
|
|
selector: 元素选择器
|
|
|
|
Returns:
|
|
bool: 是否可用
|
|
"""
|
|
return self.page.locator(selector).is_enabled(timeout=self.timeout)
|
|
|
|
def is_hidden(self, selector: str) -> bool:
|
|
"""检查元素是否隐藏
|
|
|
|
Args:
|
|
selector: 元素选择器
|
|
|
|
Returns:
|
|
bool: 是否隐藏
|
|
"""
|
|
try:
|
|
return self.page.locator(selector).is_hidden(timeout=self.timeout)
|
|
except Exception:
|
|
return True
|
|
|
|
def count(self, selector: str) -> int:
|
|
"""获取匹配元素数量
|
|
|
|
Args:
|
|
selector: 元素选择器
|
|
|
|
Returns:
|
|
int: 元素数量
|
|
"""
|
|
return self.find(selector).count()
|