- 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 合规
60 lines
1.5 KiB
Python
60 lines
1.5 KiB
Python
"""断言方法 Mixin"""
|
|
from playwright.sync_api import expect
|
|
|
|
|
|
class AssertionMixin:
|
|
"""断言相关方法
|
|
|
|
提供 Playwright expect 断言的封装。
|
|
"""
|
|
|
|
def expect_visible(self, selector: str) -> None:
|
|
"""断言元素可见
|
|
|
|
Args:
|
|
selector: 元素选择器
|
|
"""
|
|
expect(self.find(selector)).to_be_visible()
|
|
|
|
def expect_hidden(self, selector: str) -> None:
|
|
"""断言元素隐藏
|
|
|
|
Args:
|
|
selector: 元素选择器
|
|
"""
|
|
expect(self.find(selector)).to_be_hidden()
|
|
|
|
def expect_text(self, selector: str, text: str) -> None:
|
|
"""断言元素文本
|
|
|
|
Args:
|
|
selector: 元素选择器
|
|
text: 期望文本
|
|
"""
|
|
expect(self.find(selector)).to_have_text(text)
|
|
|
|
def expect_contain_text(self, selector: str, text: str) -> None:
|
|
"""断言元素包含文本
|
|
|
|
Args:
|
|
selector: 元素选择器
|
|
text: 期望包含的文本
|
|
"""
|
|
expect(self.find(selector)).to_contain_text(text)
|
|
|
|
def expect_url(self, url_pattern: str) -> None:
|
|
"""断言当前URL
|
|
|
|
Args:
|
|
url_pattern: URL 匹配模式
|
|
"""
|
|
expect(self.page).to_have_url(url_pattern)
|
|
|
|
def expect_title(self, title: str) -> None:
|
|
"""断言页面标题
|
|
|
|
Args:
|
|
title: 期望标题
|
|
"""
|
|
expect(self.page).to_have_title(title)
|