jiawei.chen 6f6053ff51 feat: TestAgent 智能测试平台 v1.0
- CLI + Web 双平台,基于 LLM 的 TDD+DDD 自动化测试生成
- 集成 unified-test-platform 903 个 D-Cloud 用例 + 13 个 Robogo 场景
- Agent 5 步流水线: 扫描 -> DDD -> LLM 生成测试
- 精确回归 + UI 变更检查
- 可视化 HTML 测试报告
- 暗色/亮色主题切换
- 19 个 API 端点 + 6 个 SPA 页面
- 15/15 项 TDD+DDD 合规
2026-07-08 11:27:38 +08:00

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()