TBC/tests/base/mixins/table.py
d-robotics 633a797226 AutoFlow v2.0: 合并 Test (Robogo) + data-loop-automation (D-Cloud) 为统一平台
- 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 模块
2026-06-23 11:48:29 +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)