TBC/tests/base/mixins/table.py
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

65 lines
1.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""表格操作 Mixin"""
class TableMixin:
"""表格操作相关
提供表格数据获取、行数统计等操作。
"""
def get_table_headers(self, table_selector: str = ".ant-table") -> list:
"""获取表格表头列表
Args:
table_selector: 表格选择器
Returns:
list: 表头文本列表
"""
headers = self.page.locator(
f"{table_selector} .ant-table-thead th"
).all_text_contents()
return [h.strip() for h in headers if h.strip()]
def get_table_row_count(self, table_selector: str = ".ant-table") -> int:
"""获取表格数据行数
Args:
table_selector: 表格选择器
Returns:
int: 数据行数
"""
return self.page.locator(f"{table_selector} tbody tr").count()
def has_table_data(self, table_selector: str = ".ant-table") -> bool:
"""检查表格是否有数据(非空状态)
Args:
table_selector: 表格选择器
Returns:
bool: 是否有数据
"""
return (
self.page.locator(f"{table_selector} .ant-empty-description").count() == 0
)
def get_table_cell_text(
self, row: int, col: int, table_selector: str = ".ant-table"
) -> str:
"""获取表格指定单元格文本
Args:
row: 行号(1 开始)
col: 列号(1 开始)
table_selector: 表格选择器
Returns:
str: 单元格文本
"""
cell = self.page.locator(
f"{table_selector} tbody tr:nth-child({row}) td:nth-child({col})"
)
return cell.inner_text(timeout=self.timeout)